Correlation ID
ELI5 — The Vibe Check
A correlation ID is like a tracking number for a request as it bounces between microservices. When a user's request touches 5 different services, the correlation ID ties all the logs together. Without it, debugging distributed systems is like finding a needle in a haystack — blindfolded.
Real Talk
A correlation ID is a unique identifier propagated through all services and components handling a single request. It's typically generated at the API gateway or first service and passed via headers (X-Correlation-ID). It enables end-to-end request tracing across distributed systems by linking logs, metrics, and spans from different services.
Show Me The Code
app.use((req, res, next) => {
req.correlationId = req.headers['x-correlation-id'] || uuid();
res.setHeader('X-Correlation-ID', req.correlationId);
logger.addContext('correlationId', req.correlationId);
next();
});
When You'll Hear This
"Search the logs by correlation ID to trace the request across all services." / "Every microservice must forward the correlation ID to downstream calls."
Related Terms
Distributed Tracing
Distributed tracing is request tracing's big brother — it works across multiple services, servers, and even data centers.
Logging
Logging is writing a diary for your program.
Microservice
Microservices is an architecture where instead of one big app, you have many tiny apps that each do one thing.
Request Tracing
Request tracing follows a request's entire journey through your system, recording every service it touches and how long each step takes.