What is distributed tracing, and what are a trace, a span and a span context?

BeginnerConceptTracing & OpenTelemetry
Answer

Distributed tracing records the path of one request as it crosses services, queues and databases, so you can see where the time went and where it failed.

  • Trace: the whole request, identified by a 128-bit trace_id.
  • Span: one unit of work inside it (an HTTP handler, a SQL query, a Kafka publish), with a start time, duration and a 64-bit span_id.
  • Span context: the small, immutable part that travels between processes: trace_id, span_id, trace flags (sampled or not) and trace state.

Spans point to their parent span, which is how the backend rebuilds the tree (the "waterfall" view). Metrics tell you that p99 is high; a trace tells you which hop made it high.

All Monitoring & Observability questions Roadmap: Logging & tracing

More on Tracing & OpenTelemetry