Skip to main content

SpanProperties

Trait SpanProperties 

Source
pub trait SpanProperties {
    type Attribute<'a>: AttributeLike
       where Self: 'a;

    // Required methods
    fn operation_name(&self) -> Cow<'_, str>;
    fn service(&self) -> Cow<'_, str>;
    fn env(&self) -> Cow<'_, str>;
    fn resource(&self) -> Cow<'_, str>;
    fn status_code(&self) -> Option<u32>;
    fn attributes(&self) -> impl Iterator<Item = Self::Attribute<'_>> + '_;
    fn get_alternate_key<'b>(&self, key: &'b str) -> Option<Cow<'b, str>>;
}
Expand description

A trait for accessing span properties needed for sampling decisions.

Provides methods for retrieving span metadata like operation name, service, environment, resource name, and status codes used by sampling rules.

Required Associated Types§

Source

type Attribute<'a>: AttributeLike where Self: 'a

The type of attribute that implements AttributeLike.

Required Methods§

Source

fn operation_name(&self) -> Cow<'_, str>

Returns the operation name for the span.

The operation name is derived from span attributes and kind according to OpenTelemetry semantic conventions.

Source

fn service(&self) -> Cow<'_, str>

Returns the service name for the span.

The service name is extracted from resource attributes.

Source

fn env(&self) -> Cow<'_, str>

Returns the environment name for the span.

The environment is extracted from span or resource attributes.

Source

fn resource(&self) -> Cow<'_, str>

Returns the resource name for the span.

The resource name is derived from span attributes and kind.

Source

fn status_code(&self) -> Option<u32>

Returns the HTTP status code if present.

Returns None if the span does not have an HTTP status code attribute.

Source

fn attributes(&self) -> impl Iterator<Item = Self::Attribute<'_>> + '_

Returns an iterator over span attributes.

Source

fn get_alternate_key<'b>(&self, key: &'b str) -> Option<Cow<'b, str>>

Returns an alternate key for the given attribute key.

This is used for mapping between different attribute naming conventions (e.g., OpenTelemetry to Datadog). Returns Some(alternate_key) if a mapping exists, or None if the attribute key has no alternate mapping.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§