Struct opentelemetry::sdk::trace::TracerProvider
source · pub struct TracerProvider { /* private fields */ }
Available on crate feature
trace
only.Expand description
Creator and registry of named Tracer
instances.
Implementations§
source§impl TracerProvider
impl TracerProvider
sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Create a new TracerProvider
builder.
sourcepub fn span_processors(&self) -> &Vec<Box<dyn SpanProcessor, Global>, Global>
pub fn span_processors(&self) -> &Vec<Box<dyn SpanProcessor, Global>, Global>
Span processors associated with this provider
sourcepub fn force_flush(&self) -> Vec<Result<(), TraceError>, Global>
pub fn force_flush(&self) -> Vec<Result<(), TraceError>, Global>
Force flush all remaining spans in span processors and return results.
Examples
use opentelemetry_api::global;
use opentelemetry_sdk::trace::TracerProvider;
fn init_tracing() -> TracerProvider {
let provider = TracerProvider::default();
// Set provider to be used as global tracer provider
let _ = global::set_tracer_provider(provider.clone());
provider
}
fn main() {
let provider = init_tracing();
// create spans..
// force all spans to flush
for result in provider.force_flush() {
if let Err(err) = result {
// .. handle flush error
}
}
// create more spans..
// dropping provider and shutting down global provider ensure all
// remaining spans are exported
drop(provider);
global::shutdown_tracer_provider();
}
Trait Implementations§
source§impl Clone for TracerProvider
impl Clone for TracerProvider
source§fn clone(&self) -> TracerProvider
fn clone(&self) -> TracerProvider
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TracerProvider
impl Debug for TracerProvider
source§impl Default for TracerProvider
impl Default for TracerProvider
source§fn default() -> TracerProvider
fn default() -> TracerProvider
Returns the “default value” for a type. Read more
source§impl TracerProvider for TracerProvider
impl TracerProvider for TracerProvider
source§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, Global>>
) -> <TracerProvider as TracerProvider>::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, Global>> ) -> <TracerProvider as TracerProvider>::Tracer
Create a new versioned Tracer
instance.
source§fn library_tracer(
&self,
library: Arc<InstrumentationLibrary, Global>
) -> <TracerProvider as TracerProvider>::Tracer
fn library_tracer( &self, library: Arc<InstrumentationLibrary, Global> ) -> <TracerProvider as TracerProvider>::Tracer
Returns a new versioned tracer with the given instrumentation library. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for TracerProvider
impl Send for TracerProvider
impl Sync for TracerProvider
impl Unpin for TracerProvider
impl !UnwindSafe for TracerProvider
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<S, T, P> ObjectSafeTracerProvider for Pwhere
S: Span + Send + Sync + 'static,
T: Tracer<Span = S> + Send + Sync + 'static,
P: TracerProvider<Tracer = T>,
impl<S, T, P> ObjectSafeTracerProvider for Pwhere S: Span + Send + Sync + 'static, T: Tracer<Span = S> + Send + Sync + 'static, P: TracerProvider<Tracer = T>,
source§fn boxed_tracer(
&self,
library: Arc<InstrumentationLibrary, Global>
) -> Box<dyn ObjectSafeTracer + Send + Sync, Global>
fn boxed_tracer( &self, library: Arc<InstrumentationLibrary, Global> ) -> Box<dyn ObjectSafeTracer + Send + Sync, Global>
Return a versioned boxed tracer