Request ID + structured logging (Express + pino)

13410
0

Debugging distributed requests is miserable without a stable request id, so I generate it once at the edge, echo it back via x-request-id, and attach it to every log line with a child logger. I keep this intentionally boring because it delivers 80% of the value without a full tracing stack. I like pino because it’s fast and the structured JSON logs ship cleanly to most backends. The real payoff shows up when I’m chasing a production 500: I can grep by requestId and reconstruct the request lifecycle (start → downstream calls → finish) instead of guessing. Once this is in, I can also correlate backend errors to frontend reports by request id.