Follow one request through many services and see where the time went.
Distributed tracing follows one request as it travels through many services, and records how long each step took.
In a monolith, a slow request is easy to study: one process, one log, one profiler. With microservices, one click can trigger calls to ten services, three databases and a cache. Each service has its own logs and its own metrics. A metric can say "checkout is slow", but not "the bank call inside payment-service is slow".
Tracing solves this. When a request enters the system, it gets a unique trace id. Each unit of work creates a span with a start time, a duration, a name, and a parent span id. The spans form a tree: the gateway span is the parent, and every call it makes is a child.
The caller adds the trace context to the outgoing request (an HTTP header, or a message header on a queue). The next service reads it, creates its own spans under the same trace id, and passes it on. The standard header is W3C Trace Context, called traceparent.
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
| Part | What it is | Typical content |
|---|---|---|
| Trace | The full journey of one request | A trace id shared by all spans |
| Span | One unit of work | Name, start time, duration, status, own span id and parent span id |
| Attributes (tags) | Facts about a span | http.method, db.statement (careful), user tier, region |
| Events / logs on a span | Things that happened inside a span | Retry 2 of 3, cache miss |
| Context | What is passed between services | Trace id, parent span id, sampling flag |
At high traffic, storing every trace is too costly. So systems sample: they keep only some. The big question is when to decide.
| Piece | Job |
|---|---|
| Instrumentation (SDK or agent) | Creates spans in your code and libraries. OpenTelemetry is the common standard. |
| Collector | Receives spans, can batch, filter, sample and forward them |
| Storage and UI | Stores traces and draws the waterfall (Jaeger, Zipkin, Grafana Tempo, and commercial tools) |
1. One request through four services
2. Keeping every trace is too costly: sampling
Span timings and request counts are illustrative (a fixed example, not a real system). In this model 2% of requests are slow.
{"time":"2026-12-03T10:15:02Z","level":"error","service":"payment",
"trace_id":"4bf92f3577b34da6a3ce929d0e0e4736","span_id":"00f067aa0ba902b7",
"msg":"bank API timeout after 3000 ms"}| Term | Meaning in easy words |
|---|---|
| Trace | The complete record of one request as it moves through the system |
| Span | One timed unit of work inside a trace |
| Trace id | A unique id shared by every span of one trace |
| Span id / parent span id | The id of this span, and the id of the span that called it |
| Root span | The first span of a trace, which has no parent |
| Context propagation | Passing the trace id and parent id from one service to the next |
| traceparent | The W3C standard HTTP header that carries trace context |
| Instrumentation | Code or an agent that creates spans automatically or by hand |
| OpenTelemetry (OTel) | An open standard and toolkit for traces, metrics and logs |
| Head / tail sampling | Deciding to keep a trace at the start, or after the request has finished |
| Waterfall (flame) view | The chart that shows spans as bars along a time axis |
| Choice | We gain | We lose |
|---|---|---|
| Keep every trace | Nothing is missing | Very high storage and network cost |
| Head sampling | Simple and cheap | May drop the rare slow or failed requests |
| Tail sampling | Keeps all errors and slow requests | Needs memory and a collector that sees all spans of a trace |
| Auto-instrumentation only | Quick start, little code | Misses your business steps and may be noisy |
| Many custom spans | Rich detail | More overhead, more clutter and more cost |
| Vendor agent | Easy and feature rich | Harder to move away later (use OpenTelemetry to reduce this) |