- Spans arrive at the OpenTelemetry Collector and are buffered until the trace completes or
decision_waitexpires. - The tail sampler evaluates configured policies in order.
- The first matching policy determines whether the trace is kept; otherwise fallback rules (rate allocation, probabilistic rules) apply.
- Kept traces are exported; others are dropped.

decision_wait, and behavior
The decision_wait parameter controls how long the collector waits for late-arriving spans before making a sampling decision. Typical values are a few seconds (for example, 5s). Policies are evaluated in the configured order — the first matching policy decides to keep a trace.
Detailed example showing multiple policy types, a decision wait, and rate allocation:
| Policy Type | Purpose | Example snippet |
|---|---|---|
| Status code | Retain traces with error/failed status | status_codes: ["ERROR"] |
| Latency | Capture slow requests exceeding a threshold | threshold_ms: 1200 |
| Spans count | Keep high-complexity traces with many spans | min_spans: 50 |
| Attribute match | Retain traces from important tenants/services | key: tenant / values: ["vip"] |
| Rate limiting | Cap throughput to limit resource usage | spans_per_second: 2000 |
| Rate allocation | Sample a percentage of remaining traces | percentage: 5 |
- The status code policy retains traces containing errors.
- The latency policy retains traces slower than 1200 ms.
- The spans count policy retains traces with many spans (e.g., >= 50).
- The attribute policy retains traces containing
tenant: "vip". - The rate-limiting policy caps throughput (e.g., 2000 spans/sec).
- The rate allocation policy samples a percentage of traces that didn’t match earlier rules (e.g., 5%).
Set an appropriate
decision_wait (for example, decision_wait: 5s) to balance waiting for late spans against export latency. Monitor late-span patterns and tune this value to match your environment.| Trade-off | Impact |
|---|---|
| Memory pressure | Traces are buffered until completion; memory usage increases with traffic and trace duration. |
| Added latency | Export decisions are delayed until the trace completes (plus decision_wait). |
| Correctness | All spans for a trace must reach the same collector for accurate decisions. |
| Late spans / timeouts | Spans arriving after buffer expiry are dropped, potentially causing incomplete traces. |

- Head sampler (application or edge collector): perform early probabilistic sampling to reduce telemetry volume and cost.
- Tail sampler (downstream collector): retain outcome-relevant traces such as errors, slow traces, or traces from important tenants or services.

- Deploy a first layer of stateless collectors (or edge collectors).
- Use a load-balancing exporter with consistent hashing (trace ID as the routing key) to route spans for the same trace to the same downstream stateful collector instance (e.g., a StatefulSet).
- The downstream collectors perform tail sampling on complete traces.
memory_limiter, batch, and decision_wait accordingly.
If spans for a trace are routed to different collectors, tail sampling decisions will be inaccurate. Use consistent hashing (trace ID) in the load-balancing exporter to maintain trace integrity.
- Use head sampling to control telemetry volume early and reduce costs; use tail sampling to retain traces that matter based on full trace outcomes.
- Tail sampling is especially valuable where retaining all traces is infeasible but outcome-relevant traces must be preserved.
- For correct tail sampling at scale, route all spans of a trace to the same collector using consistent hashing on the trace ID.
- Monitor and tune:
decision_wait,memory_limiter, and batching parameters to balance memory usage, latency, and sampling accuracy. - Consider hybrid architectures (head + tail) to achieve both cost efficiency and diagnostic fidelity.

- OpenTelemetry Collector documentation: https://opentelemetry.io/docs/collector/
- Consistent hashing overview: https://en.wikipedia.org/wiki/Consistent_hashing
- OpenTelemetry sampling concepts: https://opentelemetry.io/docs/concepts/sampling/