Conversation
…ck aggregation Implements single-line access log format inspired by nginx/envoy. Instead of multiple log lines per request, all events are aggregated into a single condensed entry when the request completes. Features: - Request stack aggregation: collect tool, action, GitLab response timing - Single-line access log format with timestamp, client, session, method, path, status, duration, tool/action, GitLab status/duration, and details - Connection tracking: log session stats (requests, tools, errors) on close - AsyncLocalStorage for transparent context propagation through async calls - LOG_FORMAT environment variable: "condensed" (default) or "verbose" Access log format: [timestamp] ip session method path status duration | tool action | gitlab_status gitlab_duration | details Connection close format: [timestamp] CONN_CLOSE ip session duration reason | reqs=N tools=N errs=N Closes #194
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Implements a new condensed, single-line access log format by aggregating request lifecycle events into a per-request “stack”, plus separate connection-close summary logs; behavior is toggled via LOG_FORMAT (condensed vs verbose).
Changes:
- Added condensed access log formatting utilities and tracking types.
- Introduced
RequestTracker(AsyncLocalStorage-backed) andConnectionTrackerfor aggregating request/connection stats. - Wired request/connection tracking into server request handling, tool dispatch, and GitLab fetch wrapper; added unit tests for the new logging components.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/server.ts |
Adds condensed logging initialization and middleware hooks for request/connection lifecycle tracking. |
src/utils/fetch.ts |
Captures GitLab response status/duration into the current request context for access logs. |
src/handlers.ts |
Records tool/action and errors into the request stack; increments connection tool/error counters. |
src/config.ts |
Adds LOG_FORMAT parsing/configuration to select condensed vs verbose logging. |
src/logging/types.ts |
Defines request stack / connection stats and log entry types for condensed logging. |
src/logging/access-log.ts |
Implements access/connection-close line formatting and entry creation helpers. |
src/logging/request-tracker.ts |
Implements request stack tracking + AsyncLocalStorage context helpers and singleton access. |
src/logging/connection-tracker.ts |
Implements per-session connection stats tracking and close-summary logging. |
src/logging/index.ts |
Aggregates exports for the new logging subsystem. |
tests/unit/logging/access-log.test.ts |
Adds unit tests for formatting and entry creation utilities. |
tests/unit/logging/request-tracker.test.ts |
Adds unit tests for request stack lifecycle and AsyncLocalStorage context helpers. |
tests/unit/logging/connection-tracker.test.ts |
Adds unit tests for connection lifecycle tracking and close-summary formatting. |
## [6.42.0](v6.41.4...v6.42.0) (2026-01-25) ### Features * Token scope detection at startup with graceful degradation ([#190](#190)) ([28bab03](28bab03)), closes [#188](#188) ### Bug Fixes * **workitems:** use two-step approach for timeEstimate on create ([#195](#195)) ([98abf4e](98abf4e)), closes [#193](#193)
… type - All fields always present with "-" for missing values (nginx-style alignment) - Escape quotes and backslashes in log values for safe parsing - Import LogFormat from logging/types.ts to avoid type duplication - Add comments explaining close handler behavior for new sessions - Fix flaky test assertion using regex for duration matching
Test Coverage ReportOverall Coverage: 93.59%
|
Add unit tests for LOG_FORMAT environment variable parsing: - Default to 'condensed' when not set - Parse 'verbose' value - Case-insensitive parsing - Invalid values default to 'condensed'
- Add ctx (context path) and ro (read-only) fields to access log format - Capture session context and read-only state during tool execution - Fix SSE close handling: distinguish normal disconnect from abort - Fix session request counting: count initial request on session init - Update session ID on stack after session initialization - Escape newlines/tabs in log values to maintain single-line format - Add needsQuoting helper to detect control characters Access log format now: [ts] ip session ctx ro method path status dur | tool action | GL:status dur | details
In condensed mode, suppress individual "Tool called", "Connection verified", "Executing tool" INFO logs - these are aggregated into single access log line. Also fix ConnectionTracker.closeConnection to return early when disabled.
- Gate access log tracking in handlers.ts behind LOG_FORMAT=condensed - Add request tracking to SSE /messages handler: - Call connectionTracker.incrementRequests for each request - Update request stack with SSE session ID (query param vs header) - Wrap handlePostMessage in runWithRequestContextAsync
- Register access logging before rate limiter to capture 429 responses - Update docstring format to include ctx and ro fields - Correct comment about session ID availability in first request
Prevents TypeError when res.locals is undefined in test mocks.
Prevents memory leak when setEnabled(false) is called while connections are still open - connections are now always deleted from the map.
- Update request stack with SSE session ID for access log - Count initial GET /sse request in connection stats
sw-release-bot bot
pushed a commit
that referenced
this pull request
Jan 25, 2026
## [6.45.0](v6.44.0...v6.45.0) (2026-01-25) ### Features * **logging:** Implement condensed access log format with request stack aggregation ([#196](#196)) ([8871fad](8871fad)), closes [#194](#194) ### Bug Fixes * **docs:** replace hardcoded 'latest' MCPB link with versioned URL in README ([#206](#206)) ([a0266a4](a0266a4)), closes [#204](#204)
|
🎉 This PR is included in version 6.45.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LOG_FORMATenv var (condensed/verbose)Access Log Format
nginx-style alignment: All fields always present with
-for missing values.Fields:
ctx- Selected context (project/namespace path) or-ro- Read-only mode:ROif enabled,-if notExamples:
Connection Close Format
Example:
Test plan
Closes #194