Direct Answer

OpenTelemetry tail sampling is best configured in the OpenTelemetry Collector, usually through the tail_sampling processor, by evaluating complete or nearly complete traces after all relevant spans have arrived and then deciding which traces to export. The core configuration defines a trace ID-ratio policy, latency policy, status-code policy, or combinations of them, followed by a decision wait and the expected number of spans per trace. A sensible starting point is to retain 100% of traces with errors, 100% of traces lasting more than 2 seconds, and 5% of ordinary successful traces, but the right percentages depend on trace volume, debugging needs, retention requirements, and ingestion cost. Tail sampling is not automatically better than head sampling: it is most useful when important errors or slow requests are rare among millions of fast, successful traces. It also requires a Collector deployment capable of routing all spans for the same trace through the same sampling instance. Running independent stateless Collectors without trace-ID-aware load balancing can produce incomplete traces and inconsistent decisions. For a multi-team command center, the objective should not be “keep every trace”; it should be preserving operational evidence while controlling cardinality, storage, query latency, and cost.

Also worth reading: Which OpenTelemetry Sampling Strategies Should Multi-Team SaaS Operations Use in 2026? · How Should Operations Teams Control Agent Observability Costs Without Losing Visibility? · How Should Leadership Teams Design an OpenTelemetry AI Governance Architecture in 2026?

How Tail Sampling Works

Head sampling makes its decision when a trace begins, often at SDK instrumentation. Tail sampling defers the decision until the Collector has seen enough of a trace to classify it. The processor assigns each trace a final decision such as sampled or not sampled, and later-arriving spans receive that same decision. Policies can use trace duration, individual span attributes, error status, or probabilistic sampling. Multiple policies are combined according to the configured decision behavior, so an error in an otherwise slow trace can cause the whole trace to be retained. This delayed decision introduces memory and coordination costs because the Collector must buffer spans and account for traces that may still be active. The processor’s decision wait must exceed the normal maximum trace duration; if it is too short, a slow trace may be released before a later error span arrives. If it is too long, memory use rises and Collector restart or deployment rollouts can discard decisions. Tail sampling therefore changes where sampling occurs, but it does not remove the need to design instrumentation, routing, and retention policies carefully.

A Practical OpenTelemetry Configuration

The standard implementation is the tail_sampling processor in the OpenTelemetry Collector Contrib distribution. The essential structure gives the processor a decision wait of 30 seconds, sets num_traces to the expected number of concurrent traces, and defines policies for errors, latency, and a baseline sample. In a production YAML file, pipelines usually place tail_sampling after batch processing and before exporters, although exact ordering should be tested because batching and memory management can affect behavior. A trace ID-ratio policy with a fractional value of 0.05 approximates a 5% baseline sample. A latency policy with a 2,000-millisecond threshold retains traces containing a span at least that long, while a status-code policy retains traces containing errors. The exact policy syntax and aggregation behavior should be checked against the Collector version deployed, because processor options have changed over time and not every release supports every feature. Start in staging with representative traffic, then compare accepted traces against known incidents before applying the policy across the organization. A useful acceptance target is that at least 95% of deliberately injected error traces survive, while background volume falls by roughly 80%–95%.

Choosing Thresholds and Policies

Thresholds should come from measured trace distributions rather than arbitrary round numbers. Begin by recording p50, p95, and p99 trace duration, error prevalence, span-count distribution, daily trace rate, and the proportion of traces associated with high-value workflows. If only 0.2% of traces contain errors, retaining 100% of them can cost little while substantially improving incident evidence. A 10% baseline sample may be unnecessarily expensive if a service produces tens of millions of traces per day, yet 0.1% may be inadequate for diagnosing intermittent latency when there is no direct way to replay a failed request. Latency thresholds need special care because clock skew, asynchronous work, and unusually long background transactions can make a “slow trace” policy retain more traffic than expected. Span-attribute policies can preserve selected tenants, services, or operations, but broad attribute matching can create accidental high-cardinality behavior. Management should approve explicit trade-offs between evidence quality, trace retention, and budget rather than treating sampling as an engineering detail with no business consequence.

Routing, Scaling, and Reliability

Tail sampling is reliable only when all spans belonging to one trace reach a sampling instance that can make and reuse the decision. With multiple gateway replicas behind a load balancer, ordinary round-robin routing can send sibling spans to different processors, causing incomplete traces or contradictory outcomes. Use a trace-ID-aware load-balancing mechanism, consistent routing, or a shared state design supported by the chosen Collector architecture. The num_traces setting is not merely a cosmetic capacity number: it tells the processor how many traces it should expect to track concurrently, and an undersized value can increase decision or memory pressure. The Collector also needs limits and telemetry for refused spans, dropped spans, processor failures, queue length, memory use, and export failures. Test behavior during rolling restarts, Collector crashes, traffic spikes, and backend outages. If a backend is unavailable, exporters may queue data, but sampling memory can still grow. For regulated or audit-sensitive workloads, define a separate retention path instead of assuming probabilistic sampling satisfies evidence requirements. Tail sampling controls what enters the trace backend; it does not determine how long a backend keeps accepted traces.

Comparison With Other Sampling Approaches

Head sampling is simpler and more predictable because the decision occurs before a trace creates network and processing overhead. Its weakness is that it cannot know the final outcome, so errors and slow traces are lost at the same probability as successful requests. Tail sampling makes a better-informed decision, but adds buffering, state, routing complexity, and a decision delay. Deterministic sampling based on trace ID is useful when consistent behavior across services is required, yet it still follows a fixed probability rather than outcome-aware rules. Rule-based routing can send every trace to storage while reducing query visibility, but that does not reduce backend ingestion cost. A comparison should therefore include not only retained percentage, but also completeness, latency, memory, operational burden, and whether decisions survive deployment changes.

FeatureHead samplingTail sampling
Decision timingAt trace startAfter observed trace behavior
Error awarenessNot available from later spansCan retain error traces
State and memoryLowHigher, buffered trace state
Routing requirementsUsually straightforwardTrace-aware routing strongly preferred
Typical useBroad, predictable volume reductionSelective retention of valuable traces
Operational riskLost rare failuresIncomplete decisions or memory pressure
## Common Configuration Mistakes

The most common mistake is setting a decision wait below the expected longest trace, which can release a trace before its error or final span appears. Another is assuming that a 1% policy means exactly 1% of traces will be stored; multi-policy combinations, errors, retries, and backend behavior can change the result. Independent Collector replicas often receive related spans without shared routing, producing traces that never receive one consistent decision. Teams also mistake num_traces for the expected number of spans, even though the concept is tied to concurrent traces and should be sized with workload measurements. Sampling every trace from selected attribute values can unexpectedly preserve noisy internal services, while a policy based only on aggregate trace duration may miss failures that fail quickly. Finally, changing policies without a recorded baseline makes it impossible to explain why incident evidence increased or decreased. Use configuration as code, version it, test it with synthetic traces, and monitor acceptance rates by service rather than relying solely on a global percentage.

When to Act and What It Costs

Act sooner when trace volume grows faster than backend capacity, routine successful traces dominate storage, and known errors or latency incidents are too rare to survive ordinary sampling. A practical trigger is a trace volume that causes unexpected ingestion bills, unacceptable query latency, or retention shorter than the time needed to investigate an incident. Do not introduce tail sampling merely to make dashboards look cleaner if the real problem is unbounded metric cardinality, missing span attributes, or an inefficient query. For cost context, OpenTelemetry components are open source, but the actual bill comes from the tracing backend, managed OpenTelemetry services, compute, storage, network transfer, and support plans. A reduction from 100% to 5% of eligible traces can reduce trace-ingestion units by approximately 95%, but total savings will be lower if errors, high-value services, and mandatory traces remain unsampled. Compare at least three scenarios—current volume, a conservative 10% baseline, and an outcome-aware 1%–5% baseline—then include the cost of additional Collectors needed for routing and capacity. The financially defensible choice is the cheapest design that meets documented evidence and incident-response requirements.

Recommended Rollout for Multi-Team Operations

Roll out by service or trace class rather than switching the entire estate at once. First establish a 7-day baseline of trace count, storage, p95 query latency, error-trace survival, and monthly cost. Next, deploy the processor in shadow or evaluation-oriented telemetry where supported, or compare its decisions with a controlled sample without deleting all data. Inject known failures and 3-, 10-, and 60-second delayed traces to verify that errors and latency rules behave as intended. During the first production stage, retain 100% of errors, 100% of traces above 2 seconds, and 10% of other traces for 14 days, then reduce the ordinary baseline only if incident teams can still reconstruct representative cases. Record which services, teams, tenants, and incident classes are exempt from aggressive reduction. Review results weekly for the first month, with thresholds such as at least 99% survival for injected critical failures and no unexplained rise in incomplete traces. After stabilization, document ownership of policy changes and review them quarterly or after major traffic, service, or backend changes.