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
sourceimpl 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>>
pub fn span_processors(&self) -> &Vec<Box<dyn SpanProcessor>>
Span processors associated with this provider
sourcepub fn force_flush(&self) -> Vec<TraceResult<()>>
pub fn force_flush(&self) -> Vec<TraceResult<()>>
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
sourceimpl Clone for TracerProvider
impl Clone for TracerProvider
sourcefn clone(&self) -> TracerProvider
fn clone(&self) -> TracerProvider
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TracerProvider
impl Debug for TracerProvider
sourceimpl Default for TracerProvider
impl Default for TracerProvider
sourceimpl TracerProvider for TracerProvider
impl TracerProvider for TracerProvider
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more