Overview
API requests lack correlation IDs, making it impossible to trace a user action across multiple service calls in server logs. When a user reports a bug that requires analyzing 'what happened when I enrolled in course X', engineers must manually cross-reference timestamps across multiple log streams. A per-request UUID sent as X-Request-ID header enables instant log correlation.
Specifications
Features:
X-Request-ID header generated per API request (uuid v4)
- Request ID included in all
appLogger entries made during the request lifecycle
- Request ID passed to Sentry context on error events
- Server echoes
X-Request-ID in response; client logs both sent and received IDs
Tasks:
- In
axios.config.ts request interceptor, generate UUID and set headers['X-Request-ID']
- Store request ID in
logContext via pushLogContext({ requestId })
- In response interceptor, read echo'd header and log if different from sent (proxy stripping check)
- Pop log context in response interceptor cleanup
- Add unit test confirming
X-Request-ID header present on all requests
Impacted Files:
src/services/api/axios.config.ts
src/config/logging.ts
Acceptance Criteria
- Every API request carries unique
X-Request-ID header
- Request ID appears in all
appLogger entries within the request lifecycle
- Sentry error events include
requestId in extra context
- Unit test confirms UUID format and presence on all outbound requests
Overview
API requests lack correlation IDs, making it impossible to trace a user action across multiple service calls in server logs. When a user reports a bug that requires analyzing 'what happened when I enrolled in course X', engineers must manually cross-reference timestamps across multiple log streams. A per-request UUID sent as
X-Request-IDheader enables instant log correlation.Specifications
Features:
X-Request-IDheader generated per API request (uuid v4)appLoggerentries made during the request lifecycleX-Request-IDin response; client logs both sent and received IDsTasks:
axios.config.tsrequest interceptor, generate UUID and setheaders['X-Request-ID']logContextviapushLogContext({ requestId })X-Request-IDheader present on all requestsImpacted Files:
src/services/api/axios.config.tssrc/config/logging.tsAcceptance Criteria
X-Request-IDheaderappLoggerentries within the request lifecyclerequestIdin extra context