← Home ← Codex ← DEBT ← Engine
Browse by Category
+ added · updated 7d
← Back to glossary

Trace Sampling Strategies

Observability Intermediate
debt(d9/e3/b5/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9), bad sampling config (missing errors, too expensive) is invisible until incidents occur or the cloud bill arrives. OpenTelemetry config doesn't flag suboptimal sampling rates.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3), per quick_fix it's a config change: set 5-10% head sampling plus OTel Collector tail sampling rules for errors. Centralised in collector config, not code-wide.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5), sampling applies across web/cli/queue contexts and shapes what's debuggable forever after — every incident investigation depends on whether the right traces were kept.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7), per misconception developers equate sampling rate with coverage of problems, not realising error-priority sampling captures 100% of errors at 1% overall rate. Contradicts intuition about statistical sampling.

About DEBT scoring →

TL;DR

Sampling records only a fraction of traces to control cost — head-based sampling decides at start, tail-based decides at end (after seeing the full trace), enabling smart error/latency capture.

Explanation

100% trace capture is expensive at scale. Sampling strategies: (1) Head-based: decision at trace start. Simple but may miss rare errors. Fixed-rate (1%), rate-limiting (100 traces/sec), probabilistic. (2) Tail-based: decision at trace end (after all spans collected). Can prioritise errors and high-latency traces. Requires OTel Collector with tail sampling processor. (3) Priority sampling: always sample errors, sample 1% of success. (4) Adaptive: adjust rate based on traffic volume. Recommended: 1-10% head-based for normal traffic, 100% for errors and slow traces. Trace ID-based sampling: all requests with same trace ID sampled consistently across services.

Common Misconception

1% sampling means missing 99% of problems — with error-priority sampling, 100% of errors are captured even at 1% overall rate.

Why It Matters

Sampling reduces observability cost by 100x without missing important data — the key is smart sampling, not just low rate.

Common Mistakes

  • 100% sampling in production — too expensive at scale.
  • 0.1% sampling — misses too many errors.
  • Not prioritising error traces — errors sampled the same rate as successes.

Code Examples

✗ Vulnerable
# 0.1% sampling — misses most errors:
sampling:
  type: probabilistic
  sampling_percentage: 0.1
✓ Fixed
# OTel Collector tail sampling — 100% errors, 5% success:
processors:
  tail_sampling:
    decision_wait: 10s
    policies:
      - name: errors-policy
        type: status_code
        status_code: {status_codes: [ERROR]}
      - name: slow-policy
        type: latency
        latency: {threshold_ms: 1000}
      - name: base-policy
        type: probabilistic
        probabilistic: {sampling_percentage: 5}

Added 23 Mar 2026
Views 71
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 2 pings M 0 pings T 1 ping W 0 pings T 2 pings F 0 pings S 2 pings S 0 pings M 0 pings T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 1 ping T 2 pings W 0 pings T 1 ping F 0 pings S 2 pings S 0 pings M
No pings yet today
Bing 2
Google 8 Amazonbot 7 Perplexity 6 ChatGPT 5 Ahrefs 5 SEMrush 5 Bing 5 PetalBot 4 Unknown AI 3 Scrapy 3 Twitter/X 2 Meta AI 1 Applebot 1
crawler 48 crawler_json 6 pre-tracking 1
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: Medium
⚡ Quick Fix
Use 5-10% head-based sampling as a baseline. Add priority rules: 100% for errors and slow traces. Use OTel Collector tail sampling processor for smart sampling.
📦 Applies To
web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
sampling|tail_sampling
Auto-detectable: ✗ No opentelemetry
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant