01Decision
Inject a UUID per request in middleware and bind it into structlog contextvars, returning it on X-Request-ID.
over Per-module logging with no correlation identifier.
- The pressure
- Four people are changing four layers, and a log line that cannot be tied to the request that produced it cannot separate a modelling error from an ingestion error.
- Why this way
- Binding into contextvars means every line emitted anywhere during that request carries the id without a single call site passing it — through middleware, handlers and services alike. Returning it on the header means the caller can quote the id for their own failed request.
- What it cost and bought
- Full request tracing costs one middleware and one header, with no tracing backend to run.