Head-based vs tail-based sampling: what is the difference?
IntermediateConceptTracing & OpenTelemetry
Answer
- Head-based: the decision is made when the root span starts (e.g. keep 10%) and propagated in the
sampledflag. Cheap and simple, but blind: it drops 90% of errors and slow requests too. - Tail-based: all spans are buffered until the trace is complete (or a timeout), then a policy decides: keep all errors, all traces over 1 s, and 5% of the rest. Much better signal, but it needs memory, a central Collector tier and trace-ID-aware routing.
| Head | Tail | |
|---|---|---|
| Where | SDK | Collector gateway |
| Cost | Very low | Buffering memory |
| Keeps all errors | No | Yes |
Common production combination: modest head sampling in the SDK (or 100% for low-volume services) plus tail sampling in the gateway.
More on Tracing & OpenTelemetry
What is distributed tracing, and what are a trace, a span and a span context?BeginnerWhat fields does an OpenTelemetry span carry?BeginnerWhat are span kinds and why do they matter?IntermediateWhat does the W3C `traceparent` header look like?IntermediateWhat is baggage, and how is it different from span attributes?IntermediateWhat is OpenTelemetry and what are its main parts?Beginner