Struct ParentBasedSampler
pub struct ParentBasedSampler { /* private fields */ }opentelemetry and trace only.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§
§impl ParentBasedSampler
impl ParentBasedSampler
pub fn new(root: impl Into<Box<dyn ShouldSample>>) -> ParentBasedSampler
pub fn new(root: impl Into<Box<dyn ShouldSample>>) -> ParentBasedSampler
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.
pub fn with_remote_parent_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> ParentBasedSampler
pub fn with_remote_parent_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> ParentBasedSampler
Sampler used when the parent’s SpanContext is remote and sampled.
Defaults to Sampler::AlwaysOn.
pub fn with_remote_parent_not_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> ParentBasedSampler
pub fn with_remote_parent_not_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> ParentBasedSampler
Sampler used when the parent’s SpanContext is remote and not sampled.
Defaults to Sampler::AlwaysOff.
pub fn with_local_parent_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> ParentBasedSampler
pub fn with_local_parent_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> ParentBasedSampler
Sampler used when the parent’s SpanContext is local and sampled.
Defaults to Sampler::AlwaysOn.
pub fn with_local_parent_not_sampled(
self,
sampler: impl Into<Box<dyn ShouldSample>>,
) -> ParentBasedSampler
pub fn with_local_parent_not_sampled( self, sampler: impl Into<Box<dyn ShouldSample>>, ) -> ParentBasedSampler
Sampler used when the parent’s SpanContext is local and not sampled.
Defaults to Sampler::AlwaysOff.
Trait Implementations§
§impl Clone for ParentBasedSampler
impl Clone for ParentBasedSampler
§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§impl Debug for ParentBasedSampler
impl Debug for ParentBasedSampler
§impl ShouldSample for ParentBasedSampler
impl ShouldSample for ParentBasedSampler
§fn should_sample(
&self,
parent_context: Option<&Context>,
trace_id: TraceId,
name: &str,
span_kind: &SpanKind,
attributes: &[KeyValue],
links: &[Link],
) -> SamplingResult
fn should_sample( &self, parent_context: Option<&Context>, trace_id: TraceId, name: &str, span_kind: &SpanKind, attributes: &[KeyValue], links: &[Link], ) -> SamplingResult
Auto Trait Implementations§
impl !RefUnwindSafe for ParentBasedSampler
impl !UnwindSafe for ParentBasedSampler
impl Freeze for ParentBasedSampler
impl Send for ParentBasedSampler
impl Sync for ParentBasedSampler
impl Unpin for ParentBasedSampler
impl UnsafeUnpin for ParentBasedSampler
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more