What Is Distributed Tracing and How Do You Read a Trace?

A user clicks checkout and waits six seconds. The request touched your API gateway, an auth service, a payment service, a database, and a queue worker, and none of them logged an error. This is the exact moment that makes you ask what is distributed tracing: a way to follow one request across every service it touches and see where the time actually went.

Without tracing, each service keeps its own logs, and you end up guessing which one was slow. With tracing, the whole journey shows up as a single timeline. You stop asking “which service is broken?” and start asking “which step in this specific request took too long?”

What Is Distributed Tracing, in Plain Terms

Distributed tracing records the path of a single request as it moves through a system made of many services. Each service adds a small record, called a span, describing what it did and how long it took. All the spans for one request are grouped into a trace.

Think of a trace as a receipt for a request. It lists every stop, the time spent at each stop, and whether anything failed. When a checkout takes six seconds, the trace shows whether the delay sat in the payment call, the database query, or the queue worker that ran after the response was already sent.

Traces, Logs, and Metrics Are Three Different Tools

People often mix these three up, so it helps to separate them. Logs record events: “payment failed at 14:02, error code 402.” Metrics record numbers over time: “average checkout latency is 800 ms.” Traces record the journey of one specific request: “this checkout spent 4.1 seconds waiting on the payment service.”

Metrics tell you something is wrong. Logs tell you what happened at one point. Traces tell you where, in a chain of services, the problem lives. You need all three, but only a trace connects the dots across service boundaries. For the full picture of how the three fit together, see our beginner guide to logs, metrics, and traces.

A common mistake is treating traces as a replacement for logs. They are not. A trace shows you the slow span; the logs attached to that span tell you why it was slow.

The Anatomy of a Trace: Spans, Context, and IDs

A trace is built from a few simple pieces. Knowing the vocabulary makes reading traces far easier.

Spans

A span is one unit of work: an HTTP request to another service, a database query, a call to a cache, a message published to a queue. Each span has a name, a start time, a duration, and a status. Spans nest inside each other, so a span for “handle checkout” can contain child spans for “validate cart” and “charge card.”

Trace IDs and span IDs

Every trace has one trace ID shared by all its spans. Each span also has its own span ID, plus the ID of its parent span. That parent link is what turns a flat list of spans into a tree. When a service receives a request, it reads the trace context from the incoming headers and passes it along to the next service it calls. If a service drops that context, its spans start a new, disconnected trace.

Attributes and events

Spans can carry attributes: key-value pairs such as the HTTP method, the route, or the database statement. Attributes are what make a trace searchable. You can ask for every trace where the payment span took longer than two seconds, or every trace for a specific customer.

How to Read a Trace: The Waterfall View

Most tracing tools show a trace as a waterfall: a horizontal bar chart where each row is a span and the length of the bar is its duration. The root span sits at the top, and child spans indent below it. Learning how to read a trace starts with scanning this view in the right order.

First, look at the total duration and the root span. If the root span is long but every child span is short, the time went somewhere the trace does not cover: the gap between spans, a thread waiting for a lock, or work happening outside any instrumented code. Gaps between bars are information, not empty space.

Second, find the longest bar. The slowest span is usually your bottleneck, but check whether it is slow because of its own work or because it is waiting on a child. A span that spends most of its time waiting on a database call is not the problem; the database call is. This is where trace spans and latency meet: the shape of the bars tells you whether time was spent working or waiting.

Third, look for red. Failed spans are usually marked in red or with an error status. A trace can have a normal total duration and still contain a failed call that was retried or swallowed by a fallback. If you debug production problems without server access, the trace is often the only record you get, and our guide to debugging production issues without SSH access shows how to pair traces with the other evidence you can still reach.

Four Patterns That Show Up Again and Again

The N+1 query

You see one span for loading a list, followed by dozens of tiny identical database spans, one per item. The fix is usually a single batched query or a join. This pattern is obvious in a trace and nearly invisible in aggregate metrics, because each individual query is fast.

The retry storm

A span fails, retries, fails again, and each retry adds its own span. The waterfall shows the same call repeated three or five times, each one waiting on a timeout. Retries turn a 200 ms failure into a multi-second request.

The slow downstream call

One child span eats most of the total time while everything else is fast. Keep following the tree downward until the long bar has no long children. That is the span doing the actual waiting. If the slow span turns out to be a database query, the steps in how to debug a slow database query apply directly: check the query plan and the indexes before you blame the application code.

The missing span

A request jumps from service A to service C with no span for service B in between. Usually B is not instrumented, or it dropped the trace context. The gap tells you where your coverage ends.

Distributed Tracing Tools and OpenTelemetry

You do not need to build a tracing system yourself. The standard starting point is OpenTelemetry, a set of libraries and a collector that instrument your code and forward spans to a backend. OpenTelemetry traces work the same way whether your backend is Jaeger, Tempo, or a commercial platform, because the libraries emit the same format and the collector handles the export.

Choosing a backend is a separate decision from choosing the instrumentation: you can swap backends without rewriting your services. If you are comparing hosted options, our comparison of Datadog vs New Relic vs Grafana for observability covers pricing and where self-hosted Grafana makes more sense than a managed service.

Sampling, Cost, and the Traces You Never See

High-traffic systems cannot keep every trace. Storing millions of traces a day gets expensive fast, so backends sample: they keep a fraction of traces and discard the rest. Head sampling decides at the start of a request whether to keep it; tail sampling waits until the trace finishes and keeps it if it looks interesting, for example because it was slow or contained an error.

Sampling has a real tradeoff. A 1% sample rate gives you a good picture of normal performance but may miss the one failing checkout a customer complained about. Tail sampling keeps the interesting traces, but it needs more infrastructure because the decision happens after the fact.

One more thing to watch: tracing adds overhead. Each span costs a little CPU and a little network traffic, and verbose attributes can bloat span sizes. Keep attribute values short and skip high-cardinality fields like raw user input.

Getting Started Without Overdoing It

The simplest useful setup is smaller than most guides suggest. Pick one user-facing flow, such as checkout or login, and instrument the services on that path. Add the OpenTelemetry SDK, send spans to a backend, and open a slow trace from real traffic. Read it the way this article describes: total duration, longest bar, waiting versus working, any red spans.

Then make tracing part of how your team actually debugs. When someone reports a slow request, the first question should be “what is the trace ID?” rather than “which service do you think it is?” A trace ID turns a vague complaint into a concrete timeline, and the habits around that question are what make tracing pay off.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.