Tracing is for performance; Correlation IDs are for debugging. It is a single, unique GUID that follows a request through every database, queue, and microservice it touches.
The API Gateway creates a `X-Correlation-ID` if one doesn't exist. This ID is then added to the **Logging Scope** of every service. When you search for this ID in Kibana, you see a chronological list of EVERYTHING that happened for that specific user request across the entire system.
We use **Middleware** to extract the Correlation ID from incoming headers and put it into an `AsyncLocal` storage. We then use a **DelegatingHandler** in our `HttpClient` calls to automatically add that same ID to outgoing headers. This ensures the chain is never broken.
Q: "What is the difference between TraceID and CorrelationID?"
Architect Answer: "Technically, they are very similar. A **TraceID** is often managed by an observability tool (like OpenTelemetry) and is used for timing and system mapping. A **CorrelationID** is often business-defined and used for log aggregation. In modern .NET 8 apps, we often use the `Activity.Current.TraceId` as our Correlation ID to reduce complexity and ensure our logs and traces are perfectly aligned."