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 THIS TESTS Whether you understand that sampling is a cost-versus-signal trade-off, and that where the decision happens changes what you can sample on.
A GOOD ANSWER COVERS 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.
COMMON WRONG ANSWERS 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).
LIKELY FOLLOW-UPS How do you ensure all spans of a trace reach the same tail collector? How do head and tail combine? What memory bounds matter?
ONE 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.
Read the original → opentelemetry.io
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.