Head-based vs tail-based trace sampling
trace sampling trade-offs.
head decides up front (cheap, may miss rare errors); tail decides after the trace completes (catches errors and slow traces but needs buffering).
claiming one is universally better.
What's really being asked
Whether you understand that sampling is a cost-versus-signal trade-off, and that where the decision happens changes what you can sample on.
The full answer
Head-based sampling makes the keep-or-drop decision when the trace begins, typically a probabilistic rate like one percent, and propagates that decision in the trace context so every downstream service agrees. It is stateless, cheap, and predictable, but because the decision precedes knowing the outcome, it drops most errors and slow requests proportionally, which is exactly what you most want to keep. Tail-based sampling defers the decision until the whole trace completes. A collector buffers all spans for a trace, then applies policies: always keep traces with errors, keep traces over a latency threshold, downsample the boring successful ones. This captures rare and pathological traces but requires holding spans in memory, routing all spans of a trace to the same collector instance, and tolerating added latency and infrastructure.
The mistakes people make
Claiming tail-based is strictly superior, ignoring its buffering and collector-affinity requirements, or thinking head-based can sample on error status (it cannot, the outcome is unknown yet).
What usually comes next
How do you ensure all spans of a trace reach the same tail collector? How do head and tail combine? What memory bounds matter?
A concrete example
At 100k requests per second, one percent head sampling keeps 1k traces but loses 99 percent of a rare 0.1 percent error class. A tail policy that always keeps error traces and samples successes at one percent retains every failing trace for debugging while still cutting volume dramatically, at the cost of running a buffering collector tier.
Interview question
Why can head-based sampling not preferentially keep traces that ended in an error?
- a.Errors are always dropped by the W3C propagation spec
- b.The keep-or-drop decision is made at trace start, before the outcome is knownCorrect
- c.Error spans are never assigned a trace ID
- d.Head sampling only runs on the collector, not the service
Why? this is the answer
Head-based sampling decides up front and propagates that choice, so the error status that only appears later cannot influence it. Tail-based sampling waits for the full trace, which is precisely why it can keep error traces.
Just read this? Test yourself on what you have been reading.
Read the original → opentelemetry.io
- #tracing
- #sampling
- #observability
- #opentelemetry
- #scalability
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles