What is Distributed Tracing and why is it essential?

Topic: microservices, Observability. Level: Intermediate.

Answer

A single user request may traverse many services; distributed tracing stitches those hops into one **trace** so you can see the end-to-end path, per-service latency, and where failures occur. A **trace id** is generated at the edge and propagated on every call (via headers like W3C `traceparent`); each hop records a **span** (with parent-child links). Tools: OpenTelemetry (instrumentation) + Jaeger/Zipkin/Tempo (storage/UI). It's essential for debugging latency and failures across service boundaries. ```java // Context propagation: the trace id flows across services via headers. // Spring Boot 3 + Micrometer Tracing auto-injects W3C traceparent: // traceparent: 00-<trace-id>-<span-id>-01 // All logs/spans for one request share the trace-id, so you can filter by it. @Observed(name = "checkout") // creates a span around this method public Receipt checkout(Cart cart) { ... } ```