Background
Requests, emitted domain events, background jobs, and outbound webhooks currently can't be correlated: a single logical operation (e.g. a payout) produces log lines and traces with no shared identifier, making incident debugging and latency attribution across async boundaries very hard. Tracing exists in common/tracing but the context is not carried across the event bus, the BullMQ job payloads, or webhook dispatch.
Implementation Plan
- Generate/accept a correlation ID at the HTTP edge (interceptor/middleware) and store it in
TracingService request context (AsyncLocalStorage)
- Include the correlation ID in every emitted domain event payload and read it back in event handlers
- Stamp the correlation ID onto enqueued job data and restore it at the start of each processor
- Add the correlation ID to outbound webhook headers and to the structured logger's context so every log line carries it
- Wire the interceptor globally in
app.module.ts
Affected Files (7–8)
BackEnd/src/common/tracing/tracing.service.ts
BackEnd/src/common/tracing/correlation-id.interceptor.ts (new)
BackEnd/src/modules/trace/trace.service.ts
BackEnd/src/modules/jobs/processors/payout.processor.ts
BackEnd/src/modules/jobs/processors/webhook.processor.ts
BackEnd/src/modules/webhooks/webhooks.service.ts
BackEnd/src/common/logger/logger.module.ts
BackEnd/src/app.module.ts
Acceptance Criteria
Background
Requests, emitted domain events, background jobs, and outbound webhooks currently can't be correlated: a single logical operation (e.g. a payout) produces log lines and traces with no shared identifier, making incident debugging and latency attribution across async boundaries very hard. Tracing exists in
common/tracingbut the context is not carried across the event bus, the BullMQ job payloads, or webhook dispatch.Implementation Plan
TracingServicerequest context (AsyncLocalStorage)app.module.tsAffected Files (7–8)
BackEnd/src/common/tracing/tracing.service.tsBackEnd/src/common/tracing/correlation-id.interceptor.ts(new)BackEnd/src/modules/trace/trace.service.tsBackEnd/src/modules/jobs/processors/payout.processor.tsBackEnd/src/modules/jobs/processors/webhook.processor.tsBackEnd/src/modules/webhooks/webhooks.service.tsBackEnd/src/common/logger/logger.module.tsBackEnd/src/app.module.tsAcceptance Criteria