Skip to main content
Tail sampling waits until a trace is complete and then decides once for the full trace. It keeps traces with errors or high latency, even when the root span looked successful at the start, and it reduces the volume that you send to Squasher.

Prerequisites

  • An OpenTelemetry Collector Contrib build (otelcol-contrib) that receives every span of a trace.
  • An ingest key in the Collector’s environment as SQUASHER_API_KEY. See Create an ingest key.

Configure the sampler

This policy keeps a trace when a span has ERROR status, when a span has an exception event, or when the trace takes more than one second. It also keeps 10 percent of the other traces.
otel-collector-config.yaml
The sampler keeps a trace when any policy matches. A longer decision_wait or a larger num_traces uses more memory. Put processors that need request context, such as Kubernetes attributes, before tail_sampling.

Send every span to the sampler

  • Sample all traces in the SDK, usually with the always_on sampler. Tail sampling cannot restore a trace that the SDK dropped.
  • Do not sample at random in each service. That splits traces before the Collector sees them.
  • Send all spans of one trace to the same Collector. With more than one Collector, route by trace ID with the OpenTelemetry load-balancing exporter. A round-robin load balancer splits traces.

What Squasher keeps

Squasher stores every span that the sampler keeps. It creates an issue only from a span with ERROR status. A trace that the sampler keeps for its exception event alone does not create an issue, so set the span status to ERROR when you record an exception.

Verify

  1. Send four traces: a fast success, a slow one, one with an ERROR span, and one with an exception event but no status.
  2. In Squasher, select Traces in the sidebar. The last three traces are there.
  3. Watch the Collector’s metrics for traces dropped before a decision, late spans, and export failures before you widen the rollout.

Limits

  • The sampler keeps spans in memory until it decides. If it drops traces too early, increase num_traces and the memory, or reduce decision_wait.
  • Tail sampling applies to traces only, not to logs or metrics.

Next steps

OpenTelemetry

See the endpoint and what Squasher does with each signal.

Durable workflows

Model retries and resumed work as linked traces.