Skip to main content
Deployment & Operations

Trace Sampling

Trace sampling is the practice of recording detailed observability traces (spans, prompts, tool calls, token counts) for a fraction of requests, balancing observability cost against debug coverage.

AIDOLS Research Team · Editorial standards

Full definition

Two strategies: head-based sampling decides at request start (cheap but biased — misses rare errors); tail-based sampling buffers traces and keeps based on outcome (catches errors and slow tails, but more expensive). For LLM apps, the typical configuration is 100% sampling on errors and high-latency requests, plus 1–10% baseline. Tools: OpenTelemetry, Langfuse, Arize Phoenix, Helicone, LangSmith.

Why it matters

Naive 100% trace logging on a high-volume LLM product can cost more than the inference itself, especially when prompts and outputs are long. Smart sampling cuts observability cost 10–100x while keeping the traces that actually matter for debugging.

Example

A SaaS team logs every LLM call to Langfuse and burns $14k/mo on storage; switching to tail sampling (100% errors, 10% baseline) drops cost to $2k/mo with no loss of debugging capability.

Next steps

More deployment & operations terms

Source & further reading

Primary source: OpenTelemetry — "Sampling" (2024).

Citation policy: this entry is part of the AIDOLS AI Implementation Glossary and may be quoted for research, journalism, and education with attribution to aidolsgroup.com/en/glossary/trace-sampling/.