intermediate

Trace IDs

Carry a trace identity across logs, metrics exemplars, HTTP headers, queues, and async work.

A trace ID identifies the entire distributed operation; span IDs identify individual steps. W3C Trace Context (`traceparent`, `tracestate`) standardizes propagation across HTTP and many messaging systems.

					traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
             │  └─ trace-id ────────────────┘ └─ parent span ─┘
             └─ version
				

Log the trace ID on every structured log line in the request path. Metrics systems can attach exemplars pointing to exemplar traces for slow histogram buckets.

On interviews: difference between trace ID and request ID, baggage for business context, and propagating through serverless cold starts.

Common pitfalls: new trace per internal hop; IDs not passed to background jobs; clients not forwarding traceparent to BFF.

The trade-off is universal correlation versus vendor-specific header history in older services.

Checklist:

  • Use W3C headers where possible.
  • Inject trace ID into logger context.
  • Continue trace across async boundaries.
  • Document header contract between teams.