Tutorials Microservices & Event-Driven Architecture (EDA) Mastery

Correlation IDs: Tracking requests across services

On this page

The Thread that Binds

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.

1. Generating the ID

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.

2. Propagation in .NET

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.

4. Interview Mastery

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."

Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

Microservices & Event-Driven Architecture (EDA) Mastery
Course syllabus
1. Foundations of Microservices
2. Communication Patterns
3. Event-Driven Architecture (EDA)
4. Distributed Transactions & Resiliency
5. Observability & Monitoring
6. Security & Identity
7. Infrastructure & Deployment
8. FAANG Microservices Case Studies
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details