Skip to main content

Module sampling

Module sampling 

Source
Expand description

Head sampler — per (full_name, sev) rate decision.

Spec 13 § 6, spec 11 § 4.1 step 4.

Decision order, mirroring spec 13 § 6:

  1. Inbound traceparent.sampled — when set on the active scope frame, the upstream caller already decided. Returns SamplingDecision::ParentSet { sampled } so the caller stamps sampling_reason = OVERRIDE on emit.
  2. Severity floor (always_log_at_or_above) — bypasses sampling.
  3. Per-event rate from config; otherwise the global default rate.

The implementation uses fastrand::f64()-equivalent behaviour via rand-free path — we cheat with a per-thread XorShift to keep the runtime out of the rand dependency tree on the hot path.

Enums§

SamplingDecision
Outcome of the head-sampler decision.

Functions§

decide
Run the head sampler. inbound_sampled is the traceparent.sampled bit lifted off the active scope frame; pass None when no scope is active or the caller did not propagate W3C trace context.