SYSTEM-DESIGN Contents

Correlation IDs and Context Propagation

Correlation IDs connect logs across services. Propagate request context reliably to make debugging fast and incident response actionable.

On this page

Correlation IDs Connect the Dots

In distributed systems, a single user request can span multiple services. Correlation IDs (or trace IDs) allow you to follow a request end-to-end across logs and services.

Propagation Strategy

Generate a request ID at the edge and propagate it through headers to downstream services. Every service logs the same ID.

Incoming request:
X-Request-Id: 7f9e...

Service A logs requestId
Service A calls Service B with same header
Service B logs same requestId

Why It Matters

Without correlation IDs, debugging requires guesswork and timestamp matching. With them, you can reconstruct the exact execution path quickly.

Production-First Takeaway

Make correlation IDs mandatory for all services. Enforce propagation at gateways and middleware layers.