Span Sampling Decisions
You'll learn how tracing systems decide which spans to keep and how those decisions flow through an entire trace.
What Are Sampling Decisions?
Not every trace needs to be recorded—at high traffic volumes, storing everything would overwhelm your backend. Sampling decisions determine whether a trace will be collected or discarded. The crucial insight: this decision must be made early (often at the very first span, called the root or head) and propagated consistently to all child spans. If you keep the root span but drop its children, you lose the full request path. If you keep children but drop the root, those orphaned spans are useless.
When and How Decisions Are Made
When the root span is created (e.g., when a request enters your system), a sampling decision is made:
- Keep this trace: Sample flag = true
- Drop this trace: Sample flag = false
This decision becomes part of the trace context (which you learned includes Trace ID, Span ID, and flags). As the trace context propagates across services via HTTP headers or message metadata, every downstream service sees the sampling decision and honors it—creating spans only if the flag says "yes."
Why Consistency Matters
Think of it like filming a movie scene: you either record all camera angles or none. Recording only some angles leaves gaps. Similarly, partial traces (some spans sampled, others not) break the parent-child relationships that make distributed tracing valuable for debugging slow requests.
Key Takeaway:
Sampling decisions are made at trace creation (usually the root span) and propagated through trace context to ensure all spans in a trace are either kept or discarded together, maintaining trace integrity.