Tracing a Request
System Design: lesson 17 of 17
One request, one tree of spans, one honest answer about the time.
Lesson 17 of 17 · 6 min
Tracing a Request
Step 1 of 10
A dashboard says the search page got slow. A trace says which hop did.
The Idea
A trace is a tree of spans. Each span carries a name, a start, a duration and a parent, so the shape of the tree is the shape of the request. A trace id and the current span id ride along in the headers — that is the only reason hops in separate services land in one picture.
Real-World Example
A parcel with a tracking number, scanned at every depot. Without that number on the label each depot still keeps a perfectly good log, and nobody can say where the two lost days went.
The Tradeoff
Recording every request is expensive, so almost everyone samples. Head sampling is cheap and discards exactly the rare slow request you needed. Tail sampling keeps the interesting traces but must buffer every span until the trace ends, which costs memory at the collector.
Your turn
Put the steps in the right order.
- The gateway opens a root span and mints a trace id
- Each service ships its finished spans to the collector
- Every outbound call carries the trace id and the caller's span id
- The collector groups spans by trace id and rebuilds the tree
Mini quiz
1 / 3