← Lessons

quiz vs the machine

Gold1440

System Design

Distributed Tracing and Spans

Modeling one request across many services as a tree of timed spans.

5 min read · core · beat Gold to climb

Following one request

In a microservice system a single user action may touch a dozen services. Distributed tracing records that journey so you can see exactly where time went and which hop failed.

Spans and traces

  • A span represents one unit of work, such as one service handling one call. It has a start time, a duration, a name, and attributes.
  • A trace is the whole tree of spans for one request, linked together.
  • Each span carries a trace id shared by the whole request and a span id, plus a parent span id that records who called it.

Because parent ids link spans, the collector can rebuild the call tree even though spans arrive separately and out of order.

What it reveals

  • The critical path, showing which span dominated total latency.
  • Fan out where one call spawns many parallel children.
  • Errors localized to the exact failing service and operation.

A waterfall view stacks spans by start time and width so slow segments are obvious at a glance.

Key idea

A trace is a tree of spans sharing one trace id and linked by parent ids, letting you pinpoint where latency and errors occur across services.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a single span represent?

2. What links spans into one trace tree?

3. What does the critical path of a trace show?