pub trait TracerProvider {
    type Tracer: Tracer;

    // Required methods
    fn versioned_tracer(
        &self,
        name: impl Into<Cow<'static, str>>,
        version: Option<&'static str>,
        schema_url: Option<&'static str>
    ) -> Self::Tracer;
    fn force_flush(&self) -> Vec<TraceResult<()>>;

    // Provided method
    fn tracer(&self, name: impl Into<Cow<'static, str>>) -> Self::Tracer { ... }
}
Expand description

Types that can create instances of Tracer.

Required Associated Types§

source

type Tracer: Tracer

The Tracer type that this provider will return.

Required Methods§

source

fn versioned_tracer( &self, name: impl Into<Cow<'static, str>>, version: Option<&'static str>, schema_url: Option<&'static str> ) -> Self::Tracer

Returns a new versioned tracer with a given name.

The name should be the application name or the name of the library providing instrumentation. If the name is empty, then an implementation-defined default name may be used instead.

Examples
use opentelemetry::{global, trace::TracerProvider};

let provider = global::tracer_provider();

// tracer used in applications/binaries
let tracer = provider.tracer("my_app");

// tracer used in libraries/crates that optionally includes version and schema url
let tracer = provider.versioned_tracer(
    "my_library",
    Some(env!("CARGO_PKG_VERSION")),
    Some("https://opentelemetry.io/schema/1.0.0")
);
source

fn force_flush(&self) -> Vec<TraceResult<()>>

Force flush all remaining spans in span processors and return results.

Provided Methods§

source

fn tracer(&self, name: impl Into<Cow<'static, str>>) -> Self::Tracer

Returns a new tracer with the given name.

The name should be the application name or the name of the library providing instrumentation. If the name is empty, then an implementation-defined default name may be used instead.

Examples
use opentelemetry::{global, trace::TracerProvider};

let provider = global::tracer_provider();

// tracer used in applications/binaries
let tracer = provider.tracer("my_app");

// tracer used in libraries/crates that optionally includes version and schema url
let tracer = provider.versioned_tracer(
    "my_library",
    Some(env!("CARGO_PKG_VERSION")),
    Some("https://opentelemetry.io/schema/1.0.0")
);

Object Safety§

This trait is not object safe.

Implementors§