Cloud
Correlation IDs
Request and correlation ID propagation for distributed tracing.
Overview
The correlation ID middleware assigns a unique request ID to every incoming
request and propagates a correlation ID across service boundaries. Both IDs
are attached to req.locals and injected into response headers.
Usage
typescript
Response Headers
The middleware automatically echoes IDs in response headers:
| Header | Description |
|---|---|
X-Request-Id | Unique ID for this specific request |
X-Correlation-Id | Shared ID across a chain of service calls |
Propagating Across Services
When calling downstream services, forward the correlation ID:
typescript
The downstream service's correlationId() middleware will preserve the
incoming correlation ID while generating a new request ID.
Options
typescript
Integration with Observability
Correlation IDs integrate with @axiljs/observability tracing:
typescript