pub struct Sampler { /* private fields */ }Expand description
Sampler that makes per-flow sampling decisions.
§Thread-safety
Immutable after creation. Safe to share across tasks.
Implementations§
Source§impl Sampler
impl Sampler
Sourcepub fn new(config: &TracingConfig) -> Self
pub fn new(config: &TracingConfig) -> Self
Create a new sampler from configuration.
§COLD PATH
Sourcepub fn should_sample_head(&self, trace_id_bytes: &[u8; 16]) -> SamplingDecision
pub fn should_sample_head(&self, trace_id_bytes: &[u8; 16]) -> SamplingDecision
Make a head-based sampling decision for a new flow.
Uses a deterministic hash of the trace ID so sampling is reproducible.
§COLD PATH — called once per flow.
Sourcepub fn should_promote_error(&self) -> bool
pub fn should_promote_error(&self) -> bool
Check if a flow should be promoted due to an error.
§WARM PATH — called when an error occurs.
Sourcepub fn should_promote_latency(&self, latency_ns: u64) -> bool
pub fn should_promote_latency(&self, latency_ns: u64) -> bool
Check if a flow should be promoted due to high latency.
§WARM PATH — called at flow completion.
Auto Trait Implementations§
impl Forget for Sampler
impl Freeze for Sampler
impl Move for Sampler
impl RefUnwindSafe for Sampler
impl Send for Sampler
impl Sync for Sampler
impl Unpin for Sampler
impl UnsafeUnpin for Sampler
impl UnwindSafe for Sampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more