Skip to main content

Sampler

Struct Sampler 

Source
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

Source

pub fn new(config: &TracingConfig) -> Self

Create a new sampler from configuration.

§COLD PATH
Source

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.
Source

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.
Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.