SimuVedaSystem Design Lab Open in the lab

Observability / Intermediate / 5 min / Updated

Trace sampling: head vs tail and the errors you lose

Keep 1% of traces with a coin flip and you lose 99% of the errors. Tail sampling keeps every error and slow request but needs collector memory.

Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.

In short

What is trace sampling?

Head sampling keeps a random share at the start; tail sampling decides after the trace ends and keeps errors and slow ones.

Why does it matter?

Keeping every trace is too costly, but the traces you need most are the rare failures.

What is the trade-off?

Head is cheap and simple but blind to errors; tail keeps the useful traces but needs a collector buffering the window.

How do you explain it in an interview?

"1-5% head sampling at the edge plus a tail-sampling collector that keeps all errors and p99-slow traces."

Check yourself

With 1% head sampling, what share of error traces is kept?

Answer: About 1%. The decision is a coin flip at the start, before anyone knows the request will fail.

What does tail sampling need that head sampling does not?

Answer: A collector that holds every trace in memory until it is complete. It can only judge a trace after the last span arrives, so it buffers traffic times the decision window.

Why keep all slow and error traces but only a few normal ones?

Answer: They are the ones you debug; normal ones are mostly alike. Tail sampling spends storage where the information is.

See it happen in the simulation →

trace samplinghead samplingtail samplingopentelemetry collectortracingobservability

More in observability