Services

Resources

Company

Correlation ID

A correlation ID, also called a request ID, is a unique identifier assigned to a request at its entry point and passed along to every service, queue and job that handles it. Each service writes the ID into its logs and responses. Searching for that one value then returns the whole story of the request across the system.

How it works

The gateway or first service generates an ID, such as a UUID, unless the caller already sent one. It forwards the ID in a header, for example X-Request-ID, and adds it to message metadata for async work. Every log line includes it as a field. If a checkout request passes through 4 services, one search for request_id = 7f3a9c returns all 12 log lines it produced, in order. With OpenTelemetry, the W3C traceparent trace ID, 32 hex characters, plays the same role and also links the distributed trace.

Why it matters in production

Without a shared ID, debugging one failed request means matching timestamps across services by hand. Returning the ID to the client lets support quote it in a ticket, so engineers jump straight to the exact logs and trace.

See also

On the One2N blog

Further reading

Four-panel comic about Correlation ID: A customer says checkout failed at 14:02. Four services logged thousands of lines that minute; The gateway stamps each request with an ID and every service passes it on in a header and logs it; X-Request-ID: 7f3a9c flows gateway, cart, payment, email. One...