IT lexicon › Infra & Ops › Trace sampling

Trace sampling

Infra & Ops På svenska → Updated: 2026-11-14

A technique that stores a fraction of all distributed traces instead of every trace, keeping storage and compute costs manageable at scale.

In microservice architectures, millions of traces flow per second. Keeping every trace becomes economically prohibitive. Trace sampling systematically decides which traces to keep — often based on error states (all failed requests), random sampling (every tenth request), or traffic volume. Strategies like head-based sampling (decision at entry) or tail-based sampling (decision at exit, once the outcome is known) offer different cost-versus-accuracy trade-offs. Most systems combine deterministic sampling for critical transactions with random sampling for background traffic.

Sampling creates a dilemma: low sampling rates reduce cost but can miss rare failures, while high rates preserve detail but grow expensive. The sweet spot often involves keeping traces with errors always, sampling successful requests less frequently.

← Back to the lexicon