pub trait TracerProvider {
type Tracer: Tracer;
// Required method
fn versioned_tracer(
&self,
name: impl Into<Cow<'static, str>>,
version: Option<impl Into<Cow<'static, str>>>,
schema_url: Option<impl Into<Cow<'static, str>>>,
attributes: Option<Vec<KeyValue>>,
) -> Self::Tracer;
// Provided method
fn tracer(&self, name: impl Into<Cow<'static, str>>) -> Self::Tracer { ... }
}Available on crate feature
trace only.Expand description
Required Associated Types§
Required Methods§
Sourcefn versioned_tracer(
&self,
name: impl Into<Cow<'static, str>>,
version: Option<impl Into<Cow<'static, str>>>,
schema_url: Option<impl Into<Cow<'static, str>>>,
attributes: Option<Vec<KeyValue>>,
) -> Self::Tracer
fn versioned_tracer( &self, name: impl Into<Cow<'static, str>>, version: Option<impl Into<Cow<'static, str>>>, schema_url: Option<impl Into<Cow<'static, str>>>, attributes: Option<Vec<KeyValue>>, ) -> 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 ts_opentelemetry_api::{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"),
None,
);Provided Methods§
Sourcefn tracer(&self, name: impl Into<Cow<'static, str>>) -> Self::Tracer
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 ts_opentelemetry_api::{global, trace::TracerProvider};
use ts_opentelemetry_api::KeyValue;
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"),
Some(vec![KeyValue::new("key", "value")]),
);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.