Skip to main content

SamplingData

Trait SamplingData 

Source
pub trait SamplingData {
    type TraceId: TraceIdLike;
    type Properties<'a>: SpanProperties
       where Self: 'a;

    // Required methods
    fn is_parent_sampled(&self) -> Option<bool>;
    fn trace_id(&self) -> &Self::TraceId;
    fn with_span_properties<S, T, F>(&self, s: &S, f: F) -> T
       where F: Fn(&S, &Self::Properties<'_>) -> T;
}
Expand description

A trait for accessing sampling data, combining trace ID and span properties.

This trait provides unified access to both the trace ID and span properties needed for making sampling decisions.

Required Associated Types§

Source

type TraceId: TraceIdLike

The type that implements TraceIdLike.

Source

type Properties<'a>: SpanProperties where Self: 'a

The type that implements SpanProperties.

Required Methods§

Source

fn is_parent_sampled(&self) -> Option<bool>

Returns whether the parent span was sampled.

Returns:

  • Some(true) if the parent span was sampled
  • Some(false) if the parent span was not sampled
  • None if there is no parent sampling information
Source

fn trace_id(&self) -> &Self::TraceId

Returns a reference to the trace ID.

Source

fn with_span_properties<S, T, F>(&self, s: &S, f: F) -> T
where F: Fn(&S, &Self::Properties<'_>) -> T,

Returns the span properties via a callback.

This method constructs the span properties and passes them to the provided callback function. The properties are only valid for the duration of the callback.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§