Pcornel
Observability · Distributed Tracing

Trace Sampling

Cheat sheet · https://pcornel.dk/topic.php?topic=6211

Back to the Topic

Answer

Trace sampling decides which traces to keep: head sampling (decided at start, e.g. 10 %) or tail sampling (decided after completion, e.g. keep all errors and slow traces).

Remember

Head sampling must be consistent across services (parent-based). Tail sampling in the Collector needs all spans of a trace on the same Collector instance.

First checks

  • OTEL_TRACES_SAMPLER=parentbased_traceidratio — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool check config prometheus.yml — config valid

Verify in this order

trace starts → sampling decision → kept or dropped → stored

Where it usually breaks

Different sample rates per service create broken traces.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6211

Confirmation

Confirm action

Continue?