← Back to microservices patterns map
🏷️
Microservices Pattern

Correlation ID

Thread a unique request ID through headers, logs, and downstream calls.

observe

Detailed Description

Correlation IDs are a lightweight observability baseline even before full tracing.

They let teams search logs from multiple services for one user request.

Visual Diagram

Correlation ID Flow
  Client → Gateway
           generates: X-Request-ID: req-789xyz
           passes header to all services

  UserSvc:   log { reqId: "req-789xyz", ... }
  OrderSvc:  log { reqId: "req-789xyz", ... }
  PaymentSvc:log { reqId: "req-789xyz", ... }

  Search logs: reqId=req-789xyz → full trace

Tradeoffs

Pros

Simple and immediately useful

Cons

Must be propagated consistently

Examples: X-Request-ID, express-request-id, Morgan logger