Skip to main content

Sampler

Trait Sampler 

Source
pub trait Sampler: Send + Sync {
    // Required methods
    fn should_sample(
        &self,
        trace_id: &str,
        parent_sampled: Option<bool>,
    ) -> SamplingDecision;
    fn name(&self) -> &'static str;
}
Expand description

采样器 trait:根据 trace_id 与父 span 状态做出采样决策

Required Methods§

Source

fn should_sample( &self, trace_id: &str, parent_sampled: Option<bool>, ) -> SamplingDecision

做出采样决策

§参数
  • trace_id:trace 标识(32 字符 hex)
  • parent_sampled:父 span 是否已采样(None 表示根 span)
Source

fn name(&self) -> &'static str

采样器名称(用于可观测性)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§