refactor: add request/correlation IDs to logs #9

Open
opened 2026-05-23 18:30:47 +00:00 by Klaus · 0 comments
Owner

Problem

pkg/log produces flat log lines with no per-request identifier. When multiple HTTP-mode clients are calling tools concurrently, lines from different requests interleave with no way to correlate "this error" with "that tool call".

Suggested direction

  • In the HTTP middleware (and stdio loop), generate a short request ID (8–12 chars) and store it in ctx
  • Have pkg/log read it from ctx and prefix every line
  • Echo the same ID in the outgoing X-Request-ID header to Gitea so server-side logs can join up
## Problem `pkg/log` produces flat log lines with no per-request identifier. When multiple HTTP-mode clients are calling tools concurrently, lines from different requests interleave with no way to correlate "this error" with "that tool call". ## Suggested direction - In the HTTP middleware (and stdio loop), generate a short request ID (8–12 chars) and store it in `ctx` - Have `pkg/log` read it from `ctx` and prefix every line - Echo the same ID in the outgoing `X-Request-ID` header to Gitea so server-side logs can join up
Klaus referenced this issue from a commit 2026-05-23 18:47:28 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Klaus/gitea-mcp#9