Skip to content

Sampling

SpanSlice has two sampling actions, and they work at different levels:

  • Set Sample Rate decides whether the whole trace is kept.
  • Set Span Sample Rate thins out individual spans inside a trace that was kept.
Set Sample Rate Set Span Sample Rate
Decides whether the trace is kept whether this span is kept, inside a kept trace
Kept 1 in N by trace ID, so every span of a trace agrees span ID, so each span is decided on its own
What a “no” removes the whole trace the span; its children move up to the nearest kept ancestor
SampleRate on what’s sent the trace rate trace rate × span rate
Inside For Descendant Spans no yes
When it’s decided in rule order: created rules on the root, then completed rules when the trace is sent

“Keep 1 in 10 traces” keeps a tenth of the traces the rule matches and drops the rest, along with all their spans. Every span in a kept trace carries SampleRate = 10. Honeycomb reads that attribute and counts each event as ten, so counts, sums and rates in your queries still reflect real traffic.

SpanSlice makes the keep-or-drop decision from the trace ID. Every service that uses the same rate makes the same decision for a given trace, so a sampled trace has no gaps where one service kept its part and another didn’t.

Set Span Sample Rate: keep 1 in N of a span

Section titled “Set Span Sample Rate: keep 1 in N of a span”

Some traces are worth keeping, but they contain hundreds of near-identical spans: a Redis HSCAN loop, a batch of inserts, a polling call. Set Span Sample Rate keeps 1 in N of those spans and leaves the rest of the trace alone.

  • A span that isn’t kept is dropped. Its children move up to its nearest kept ancestor, so the trace stays connected.
  • A kept span carries SampleRate = trace rate × span rate. In a trace kept 1 in 10, a span kept 1 in 5 carries SampleRate = 50, because it stands for fifty such spans.
  • SpanSlice decides it when the trace is sent. A span still open at that point keeps the rate it had.

Because it works span by span, you can put it inside For Descendant Spans. For example, on root spans:

When a root span is completed and matches Span Name is GET /reports, then For Descendant Spans matching Span Name starts with HSCAN: Set Span Sample Rate 1 in 20.

To thin out a span wherever it appears, use the action directly in a rule that targets any span:

When any span is completed and matches Span Name starts with HSCAN, then Set Span Sample Rate 1 in 20.

To remove the matching spans instead, use Drop Span. To summarize them, use Roll Up Spans, which replaces a run of like spans with one span that carries their count and timings.

Several rules can match the same trace. Both actions have a mode that says what happens when a rate is already set:

  • If Not Set (the default) applies only if no earlier rule set a rate.
  • Overriding Any Existing Sampling replaces whatever an earlier rule set.

Here, “earlier” means this order: created rules on the trace’s root first, then completed rules, span by span in the order the spans started. Within a stage, rules run in rule order.

With the default mode, the first rate set wins. A broad rule, such as “keep 1 in 10 traces”, placed after specific rules acts as a fallback. If a specific rule must win regardless, such as “keep every trace from the billing service”, set it to override.

  • Drop Trace drops the whole trace and beats every rate, including overriding ones. A Drop Trace from a created rule is final.
  • Drop Traces Without Errors drops the trace unless a span in it has an error.

A trace is sent early when it grows past the span or age limit, when more than 1,000 traces are open, or when the process shuts down. An early-sent trace skips the completed rules on its root, and it’s kept at the rate its created rules set. See spans are held until the trace is decided.