
- Lowers network and backend load by discarding unneeded spans early.
- Enables consistent per-process sampling configured without code changes.
- Limited by the local view: SDK sampling decisions occur at span creation time and cannot use eventual trace outcomes.

| Sampler | What it does | Use case |
|---|---|---|
| AlwaysOn | Records all traces | Debugging, development, short-lived tests |
| AlwaysOff | Records no traces | Disable telemetry in specific runs |
| TraceIdRatio (probabilistic) | Records a fixed percentage of traces using a hash of the trace ID | Control volume with predictable sampling rate |
| ParentBased | Follows the parent span’s decision | Preserve trace consistency across services |

Sampling at the SDK reduces network and backend load, but it discards data early. If you need sampling decisions based on full-trace results (errors, latency spikes, or aggregated attributes), consider sampling later in the pipeline (the Collector).


| Approach | How it works | Pros | Cons |
|---|---|---|---|
| Head sampling | Decide as spans arrive at the Collector (per-span or per-trace probabilistic policies based on partial info) | Low memory & CPU, fast, scalable | Cannot use full-trace outcomes (may miss important traces) |
| Tail sampling | Buffer and assemble a trace (or wait for a decision signal) and then evaluate the entire trace before keeping or dropping | Outcome-aware (keep traces with errors/latency/patterns), more accurate retention of important traces | Requires buffering, more memory and CPU, complexity in distributed systems |
Tail sampling improves retention of high-value traces but increases memory and processing needs in the Collector. Plan capacity, timeouts, and resource limits carefully to avoid buffering overload.
- Use SDK or Collector head sampling for lightweight, probabilistic reduction when you only need volume control.
- Use Collector tail sampling when you must make outcome-based decisions (for example, retain all traces that contain errors or unusually high latency).
- Combine approaches: use SDK sampling to reduce baseline volume and tail sampling in the Collector for application-level exceptions or multi-service error patterns.
- OpenTelemetry: https://opentelemetry.io/
- OpenTelemetry Collector: https://opentelemetry.io/docs/collector/
- OTTL (OpenTelemetry Transformation Language) docs: https://opentelemetry.io/docs/collector/processing/transform/