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 hasERROR 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
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_onsampler. 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 withERROR 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
- Send four traces: a fast success, a slow one, one with an
ERRORspan, and one with anexceptionevent but no status. - In Squasher, select Traces in the sidebar. The last three traces are there.
- 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_tracesand the memory, or reducedecision_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.