-
Notifications
You must be signed in to change notification settings - Fork 384
/
provider.rs
36 lines (33 loc) · 1.74 KB
/
provider.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! # OpenTelemetry Tracer Provider Interface
//!
//! ### Obtaining a Tracer
//!
//! New `Tracer` instances can be created via a `TracerProvider` and its `get_tracer`
//! method. This method expects an Into<String> argument:
//!
//! - `name` (required): This name must identify the instrumentation library (also
//! referred to as integration, e.g. `io.opentelemetry.contrib.mongodb`) and *not*
//! the instrumented library.
//! In case an invalid name (empty string) is specified, a working
//! default Tracer implementation as a fallback is returned rather than returning
//! None or throwing an exception.
//! A library, implementing the OpenTelemetry API *may* also ignore this name and
//! return a default instance for all calls, if it does not support "named"
//! functionality (e.g. an implementation which is not even observability-related).
//! A TracerProvider could also return a no-op Tracer here if application owners configure
//! the SDK to suppress telemetry produced by this library.
//!
//! Implementations might require the user to specify configuration properties at
//! `TracerProvider` creation time, or rely on external configurations.
use crate::trace::{TraceResult, Tracer};
use std::fmt;
/// An interface to create `Tracer` instances.
pub trait TracerProvider: fmt::Debug + 'static {
/// The `Tracer` type that this `TracerProvider` will return.
type Tracer: Tracer;
/// Creates a named tracer instance of `Self::Tracer`.
/// If the name is an empty string then provider uses default name.
fn get_tracer(&self, name: &'static str, version: Option<&'static str>) -> Self::Tracer;
/// Force push all remaining spans in span processors and return results.
fn force_push(&self) -> Vec<TraceResult<()>>;
}