Skip to content

Request correlation - #565

Merged
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
Dijjy7:Request-Correlation
Aug 22, 2026
Merged

Request correlation#565
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
Dijjy7:Request-Correlation

Conversation

@Dijjy7

@Dijjy7 Dijjy7 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Observable Request Correlation — Implementation Complete

What was built

New files:

  • src/common/correlation/correlation-context.service.ts  AsyncLocalStorage-backed service that propagates a correlation ID across all async contexts (HTTP, queue, DB)
  • src/common/correlation/correlation-context.module.ts  @Global() module so every service can inject it

Modified files (15 total, +342 / -79 lines):

Layer | File | Change -- | -- | -- HTTP Middleware | correlation-id.middleware.ts | Now populates AsyncLocalStorage in addition to req.correlationId and response headers App Wiring | app.module.ts, main.ts | Imports CorrelationContextModule; passes service to LoggingInterceptor Logging | logging.interceptor.ts | Reads correlation ID from AsyncLocalStorage as fallback Metrics | metrics.interceptor.ts | Emits structured JSON logs with correlationId, event, status_code, duration_ms on every HTTP request External Calls | trace-external-call.decorator.ts | Resolves correlation ID from AsyncLocalStorage first, then instance property Job Types | job.types.ts | Added `correlationId?: string Job Persistence | job.repository.ts | Stores/retrieves correlation_id column in Supabase jobs table Job Enqueue | job-queue.service.ts | Captures caller's correlation ID from AsyncLocalStorage on every enqueue/enqueueDelayed call Job Execution | job-executor.service.ts | Restores correlation ID into AsyncLocalStorage via correlationContext.run() before handler execution; all downstream calls inherit it Tests | job-queue.service.unit.spec.ts, job-executor.service.unit.spec.ts | Updated with CorrelationContextService mocks Docs | README.md | New "Request Correlation & Distributed Tracing" section explaining end-to-end tracing

Verification results:

  • TypeScript: Zero new type errors in production code
  • Tests: All 59 tests across 4 affected suites pass — no regressions
closes #563

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MaryammAli
MaryammAli merged commit bd4c845 into BlockDash-Studios:main Aug 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add observable request correlation across HTTP, queue, DB, and WebSocket layers

2 participants