pub struct ParentBasedSampler { /* private fields */ }Expand description
A ShouldSample sampler that lets each of the 5 branches defined by the
ParentBased sampler spec be configured independently: the root sampler (no
parent or an invalid parent), and a sampler for each combination of remote/local parent and
sampled/not-sampled. Any branch left unset falls back to the spec default
(Sampler::AlwaysOn for the two *_sampled branches, Sampler::AlwaysOff for
the two *_not_sampled branches).
Unlike Sampler::ParentBased, which keeps only the delegate’s SamplingDecision
and always returns the parent’s trace state with no attributes, this returns the
selected delegate’s SamplingResult unchanged, preserving any attributes it adds
and any trace state it modifies. Worth keeping in mind when moving an existing custom
root sampler over to this API.
Build one with ParentBasedSampler::new or Sampler::parent_based.
Implementations§
Source§impl ParentBasedSampler
impl ParentBasedSampler
Sourcepub fn new(root: impl Into<Box<dyn ShouldSample>>) -> Self
pub fn new(root: impl Into<Box<dyn ShouldSample>>) -> Self
Create a new ParentBasedSampler with root as the sampler used for spans with
no parent or an invalid parent.
The other 4 branches default to the [ParentBased sampler spec] values:
remote_parent_sampled:Sampler::AlwaysOnremote_parent_not_sampled:Sampler::AlwaysOfflocal_parent_sampled:Sampler::AlwaysOnlocal_parent_not_sampled:Sampler::AlwaysOff
Each of these branches can be configured using their respective with_* methods.
Sourcepub fn with_remote_parent_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> Self
pub fn with_remote_parent_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> Self
Sampler used when the parent’s SpanContext is remote and sampled.
Defaults to Sampler::AlwaysOn.
Sourcepub fn with_remote_parent_not_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> Self
pub fn with_remote_parent_not_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> Self
Sampler used when the parent’s SpanContext is remote and not sampled.
Defaults to Sampler::AlwaysOff.
Sourcepub fn with_local_parent_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> Self
pub fn with_local_parent_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> Self
Sampler used when the parent’s SpanContext is local and sampled.
Defaults to Sampler::AlwaysOn.
Sourcepub fn with_local_parent_not_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> Self
pub fn with_local_parent_not_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> Self
Sampler used when the parent’s SpanContext is local and not sampled.
Defaults to Sampler::AlwaysOff.
Trait Implementations§
Source§impl Clone for ParentBasedSampler
impl Clone for ParentBasedSampler
Source§fn clone(&self) -> ParentBasedSampler
fn clone(&self) -> ParentBasedSampler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more