pub struct Sampler { /* private fields */ }Expand description
A sampler that decides whether a trace should be recorded.
Implementations§
Source§impl Sampler
impl Sampler
Sourcepub fn new(config: SamplingConfig) -> Self
pub fn new(config: SamplingConfig) -> Self
Create a new sampler with the given configuration.
Sourcepub fn should_sample(&mut self, trace_id_low: u64, now_unix_sec: u64) -> bool
pub fn should_sample(&mut self, trace_id_low: u64, now_unix_sec: u64) -> bool
Decide whether a new root trace should be sampled.
For child spans, the decision is inherited from the parent trace context (if the parent is sampled, the child is sampled).
trace_id_low is the low 64 bits of the trace ID, used as a
deterministic hash for HeadBased sampling. now_unix_sec is the
current Unix timestamp in seconds, used for RateBased windows.
Sourcepub fn should_sample_child(parent: &TraceContext) -> bool
pub fn should_sample_child(parent: &TraceContext) -> bool
Check if a child span should be sampled, given its parent context.
If the parent is sampled, the child is always sampled (propagation).
Sourcepub fn config(&self) -> &SamplingConfig
pub fn config(&self) -> &SamplingConfig
Get the current configuration.
Auto Trait Implementations§
impl Freeze for Sampler
impl RefUnwindSafe for Sampler
impl Send for Sampler
impl Sync for Sampler
impl Unpin 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