Skip to content

Add JSONL access logging - #269

Merged
andrew merged 2 commits into
mainfrom
access-log
Aug 16, 2026
Merged

Add JSONL access logging#269
andrew merged 2 commits into
mainfrom
access-log

Conversation

@andrew

@andrew andrew commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Adds an optional JSONL access log configured with access_log.path, PROXY_ACCESS_LOG_PATH, or -access-log.

Each client request and upstream HTTP exchange is written as a separate record with a shared request ID. This preserves upstream status codes across retries and OCI authentication exchanges. URL credentials, query strings, and fragments are omitted.

Configuration examples and field documentation are included.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional JSON Lines (JSONL) access log for the proxy, recording both client-facing requests and individual upstream HTTP exchanges with a shared request ID for correlation, while omitting URL credentials, query strings, and fragments from logged URLs/paths.

Changes:

  • Add access_log.path config + PROXY_ACCESS_LOG_PATH env var + -access-log flag wiring, plus documentation and examples.
  • Introduce internal/accesslog JSONL logger + request-id context helpers.
  • Add upstream http.RoundTripper wrapper and server middleware hooks to emit request/upstream access log entries, with tests.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents the new -access-log flag, env var, and config file stanza.
internal/server/server.go Opens/closes the access log and wraps the upstream transport to emit upstream exchange records.
internal/server/middleware.go Stores request IDs using accesslog context helpers and writes per-request JSONL entries.
internal/server/middleware_test.go Adds coverage ensuring request logging writes a JSONL record with query omitted from path.
internal/httpclient/access_log.go Adds a RoundTripper wrapper that logs upstream exchanges (status/error) with sanitized URLs.
internal/httpclient/access_log_test.go Tests upstream access log records for status and error redaction behavior.
internal/config/config.go Adds AccessLog config struct and env var loading for PROXY_ACCESS_LOG_PATH.
internal/config/config_test.go Adds tests for default-disabled access log and config/env loading of the path.
internal/accesslog/accesslog.go Implements a mutex-protected JSONL file logger + URL redaction + request-id context helpers.
internal/accesslog/accesslog_test.go Adds tests for JSONL logging, request id retrieval, and URL sanitization.
docs/configuration.md Adds detailed access log documentation (fields, examples, behavior).
config.example.yaml Adds example access_log configuration.
cmd/proxy/main.go Adds -access-log flag parsing and usage/help text updates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/accesslog/accesslog_test.go
Comment thread internal/server/server.go Outdated
Comment on lines +152 to +156
var activityLog *accesslog.Logger
if cfg.AccessLog.Path != "" {
activityLog, err = accesslog.Open(cfg.AccessLog.Path)
if err != nil {
_ = store.Close()
@andrew
andrew merged commit e4fbf3f into main Aug 16, 2026
8 checks passed
@andrew
andrew deleted the access-log branch August 16, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants