Skip to content
Enterprise Tech Logic

Independent analysis for technology leaders

IT Operations

OpenTelemetry sampling: retain the trace that explains the failure

Choose head or tail sampling around the failures your team must explain, then account for collector capacity, trace routing and the true cost boundary.

By Enterprise Tech Logic

Enterprise technology, security and IT leadership

· 5 min read

Circular multicoloured light trails

At a glance

  • Choose the diagnostic evidence before the sampling percentage.
  • Tail sampling needs trace routing, capacity and failure checks.
  • Compare the entire telemetry path, not retained volume alone.

The trace you most want during an incident may be the one your sampling policy discarded before the failure happened. An observability lead under pressure to reduce ingestion spend needs to decide which diagnostic questions the remaining data must answer. “Keep ten per cent” is a volume instruction, not a statement of investigative coverage.

Start with the failures that cost the business time: an intermittent checkout error, a slow dependency after a release, or a low-volume process that occasionally stalls. The sampling design should preserve enough evidence to explain those cases without making the telemetry system disproportionately expensive to operate.

Where the decision happens changes what you can know

OpenTelemetry distinguishes head sampling from tail sampling by the information available when the decision is made. Head sampling decides early, without inspecting the whole trace. Tail sampling considers all or most of its spans and can use outcomes such as errors, latency or attributes.

Head sampling offers a relatively simple way to control volume. It cannot, on its own, guarantee retention of every trace that eventually contains an error. Tail sampling makes that outcome-based selection possible, but introduces stateful processing and an operational burden.

Combining them can be sensible when upstream volume would otherwise overwhelm the pipeline. The boundary must remain explicit: a downstream tail sampler cannot recover spans that were never exported to it. A policy described as “keep errors” therefore needs to say which incoming population it covers.

Ask service owners to choose a small number of diagnostic priorities. For each one, establish the attribute or outcome that makes a trace useful and where that information becomes available. A broad business label such as “important transaction” needs an instrumentation convention before it can become an effective selection rule.

Tail sampling adds a system that needs capacity

The OpenTelemetry Collector tail-sampling processor requires spans belonging to a trace to reach the same collector instance for a correct decision. Its guidance describes a load-balancing layer ahead of the sampling layer. Simply adding replicas does not establish that routing property.

The processor also exposes a decision wait and a limit on traces held in memory. Its documentation describes premature trace removal under load, and explains that late spans may inherit an earlier decision or be handled differently once that decision is no longer retained. Decision caches help maintain consistency; they do not make late evidence arrive before an earlier decision.

For capacity planning, measure the arrival pattern and trace shape your own applications generate. A steady average can hide a burst during a retry storm, exactly when the incident investigator needs the evidence. Include collector restarts and changes in replica count in the exercise. A configuration that works only while membership stays constant is a weak basis for an elastic service.

A historical engineering account illustrates why this matters. In June 2020, Grafana Labs described its own tail-sampling deployment and the problem of different collectors receiving fragments of the same trace. Its solution forwarded spans by trace identity before making the decision. This is a vendor’s account of its implementation at that time, not a current sizing benchmark or a reason to deploy that old component. The enduring design lesson is to test routing as part of sampling correctness.

Price the path before and after sampling

A smaller retained dataset does not automatically mean the whole observability bill falls by the same proportion. Work out where each charge or resource requirement occurs: application instrumentation, transport, collector processing, backend ingestion and retention. Then ask which of those costs your proposed sampling point can actually reduce.

In a hypothetical comparison, two designs each retain 100 out of 1,000 traces. The first selects early; the second receives all 1,000 at a tail sampler before forwarding 100. Both retain ten per cent, but the second must transport and process the larger incoming population at that stage. This says nothing about a particular supplier’s tariff. It identifies the cost boundary the commercial comparison must specify.

Include the engineer who owns policy changes and incidents in that comparison. A more elaborate sampler can be worthwhile when it preserves otherwise missing evidence, but the saving should survive the cost of maintaining it. Conversely, retaining all traces for a small, valuable service may be a reasonable choice if selective retention adds complexity without a meaningful reduction.

Judge the result by an investigation

Build a controlled workload with known outcomes: ordinary successes, a downstream error, a slow request and a delayed span. Add a low-volume route so that a busy service cannot dominate the evaluation. Agree the intended retention policy before running the workload.

Inspect the resulting traces from the investigator’s perspective. Can the team follow the failed request across the relevant services? Does the late evidence change the explanation? Can an operator distinguish a policy-driven omission from loss inside the telemetry pipeline? Repeat under a representative burst and a collector change, recording the conditions under which the promised view stops being reliable.

Be equally careful with dashboards built from the retained set. If selection deliberately favours errors and slow requests, raw proportions in that set should not be read as proportions across all traffic. Use an appropriate independently collected measure or a validated correction method for population-level reporting. Diagnostic retention and business-wide rate measurement are different uses of data.

Put the findings into observability platform evaluation as a concrete requirement: a specified failure must remain explainable at a stated workload and operating cost. Run that investigation on one important service before imposing a uniform sampling percentage across the estate.

Your next step

Observability platform evaluation: replay the incident your team could not explain

Make sampling correctness and operating cost part of observability platform evaluation.

Read the guide

Keep reading

Related insights