Quick reference
Head, tail and the errors you never drop.
Read it bottom to top: head, then tail.
| Layer | What it does | Typical tech |
|---|---|---|
| SDK sampler | Decides at span start, before the trace exists. | HEAD |
| Ratio 1 in 10 | Keeps a tenth, children follow the parent. | 10% |
| Collector tail | Waits for the whole trace, then decides. | TAIL |
| Error policy | Keeps every trace with an error span. | ERR |
| Latency policy | Keeps traces slower than the SLO. | P99 |
| Tempo | Stores what the policies kept. | STORE |
In one line: Sample the boring, keep the broken. Head sampling is cheap; tail sampling keeps the trace that explains the page.
Set the ratio:
OTEL_TRACES_SAMPLER_ARG=0.1Explained
Head sampling decides at the start of the trace, in the SDK. The trace id is hashed and one in ten traces is kept, with all its children following the parent decision. It costs almost nothing and it cannot know whether the request will fail.
Tail sampling decides at the collector, after the trace is complete. A buffer holds the spans for a few seconds, then a policy looks at the whole trace: keep it if it has an error span, keep it if it is slower than the SLO, keep a small percentage of the rest. It costs memory, and it needs every span of a trace to reach the same collector, which is why the collector fleet routes by trace id.
Errors are the policy that pays for itself. Keep every trace with an error, then cap it with a rate-limiting policy during a broad outage so a million failures do not become a million traces.
The honest caveat: tail sampling is stateful and harder to run than a ratio. Start with head sampling at ten per cent and add tail policies when the first incident needs a trace you dropped.
Your turn: Which traces would you regret dropping tomorrow?
Related on this site
More notes: Observability & SRE
Open in the notes app: search, filters, copy This note on GitHub