SD-41 · Back to the write-up
Design a Distributed Tracing
Route every span of a trace to one collector, count metrics from all of them, keep the 5% that matter, and store those as blocks in object storage.
Follow a request
A span’s journey
Tail sampling decision
Write a block
Open a trace by id
A collector crashes
Hosts
Ingest
Pipeline
Storage
Services + SDKMake spans
Host agentBatch + scrub
Routing tierHash by trace id
Collectors30 s buffer, decide
Sampling configTeam rules
Span streamKept spans + deltas
Block writers5-minute blocks
Span metricsExact rates
Trace blocksObject storage
Trace indexSlim
Query serviceUI + API
The numbers, at a glance
1 kept ≈ 2.5M/s19 counted, then dropped
≈ 2,160 TBGenerated
≈ 108 TBKept, raw
≈ 22 TBStored
2% error traces, 100% kept98% healthy, about 3% of them kept
From span to stored trace
Healthy traces that lose the 1% draw stop after step 3; their spans still count in metrics.
Service
Host agent
Collector
Span stream
Block writer
Object storage
Trace index
1 span
2 batch by trace_id
3 metric deltas
4 kept trace (after 30 s)
5 read batch
6 spans
7 PUT block + bloom
8 200
9 trace id → block
10 commit offset
RequestResponseAsync, does not block
Where to decide what to keep
The decision this question is really about.
50M spans/s
store all
2,160 TB a day
+ Nothing missing.− About 2 PB a day.
first service: 10%?
flag in traceparent
90% of errors lost
+ Free and complete traces.− Decided before errors happen.
route by trace_id
count allwait 30 s
keep errors, slow + 1%
+ Keeps every error and slow trace.− Memory to hold 30 s of traces.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Services + SDK
Collectors
Search clusterQuery
Services + SDK
Routing tier
Sampling collectors
Search clusterSpan metricsQuery
Services + SDK
Routing tier
Sampling collectorsSpan stream
Block writersTrace blocksTrace index
Services + SDKHost agents
Routing tierSampling config
Sampling collectorsSpan stream
Block writersTrace blocksTrace indexSpan metrics
Was this walkthrough useful?Your vote tells us what to improve next.