master · Module 3.3
Tail vs Head Sampling
Learning Objectives
- Contrast head sampling (decide at trace start) with tail sampling (decide after the trace completes).
- Explain why tail sampling can guarantee capture of all error and slow traces.
- Describe the memory/latency cost of buffering traces for a tail decision at the gateway.
- Choose a sampling strategy for a live match given a fixed trace budget.
Key Concepts
Head sampling
Head sampling decides keep/drop at the first span using only information available at trace start (a probability, maybe the route). It is cheap and stateless but blind — it may drop the exact error trace you needed because it could not know the trace would fail.
Tail sampling
Tail sampling buffers all spans of a trace and decides after completion, so policies can key on outcome: keep every ERROR, keep every trace over a latency threshold, and probabilistically sample the healthy baseline. This guarantees you keep the interesting traces.
Cost of the tail decision
Buffering whole traces until decision_wait costs memory and adds decision latency at the gateway, and requires all spans of a trace to reach the same Collector (span-aware routing). This is why tail sampling lives on the gateway, not the agent.
Choosing a strategy under budget
For a marquee match: tail-sample so 100% of errors and slow traces survive while the healthy baseline is sampled at a low percentage, keeping total volume within budget without losing diagnostic value.
Insight
Head sampling optimizes for cost and simplicity; tail sampling optimizes for keeping the traces you will actually want at 2am. For incident-grade OTT, tail sampling wins.
Warning
Tail sampling requires span-aware routing so ALL spans of one trace land on the same gateway Collector. Round-robin load balancing breaks the decision.
Info
decision_wait must exceed your longest expected trace, or slow traces get a decision before they finish and are misclassified.
Production Configs & Runbooks
Production configs and runbooks are a Pro feature.
Knowledge Check
1. What is the fundamental limitation of head sampling?
2. How does tail sampling guarantee capture of all error traces?
3. Why must tail sampling use span-aware (trace-ID) routing?
4. What is the primary cost introduced by tail sampling versus head sampling?