feat: add LLM request lifecycle logging with session correlation#1365
Closed
shudonglin wants to merge 1 commit intoWei-Shaw:mainfrom
Closed
feat: add LLM request lifecycle logging with session correlation#1365shudonglin wants to merge 1 commit intoWei-Shaw:mainfrom
shudonglin wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
Add comprehensive per-request structured logging for all LLM gateway requests, enabling conversation-level tracing across multi-turn sessions. Changes: - Add session_hash, client_request_id, platform columns to usage_logs table with partial indexes for efficient session queries - Create dedicated AccessLogger (JSON file, rotated via lumberjack) that emits one structured log line per LLM request with full lifecycle data: session, routing, latency, tokens, retry context - Wire access log emission into all 7 gateway handler methods (Anthropic x3, OpenAI x2, Gemini, Sora) - Add AccessLog config (enabled, file_path, include_body, rotation) - Include engineering optimization plan from codebase review Enable with ACCESS_LOG_ENABLED=true or access_log.enabled: true in config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
session_hash,client_request_id,platformcolumns tousage_logsfor conversation-level tracingAccessLoggerthat emits structured JSON log lines per LLM request (session, routing, latency, tokens, retry context)AccessLogconfig section (enable/disable, file path, body capture toggle, rotation)Config
Or env:
ACCESS_LOG_ENABLED=trueTest plan
🤖 Generated with Claude Code