[−][src]Struct opentracingrust::utils::GlobalTracer
Utility singleton to store the process's Tracer
.
Every thread in the process, may it be application or library, should use
the same Tracer
instance for the entire lifetime of the process.
Applications should initialise the
GlobalTracer::init
as soon as possible!The
GlobalTracer::init
method is NOT thread safe and MUST be called before any thread is spawned or threads will panic!
The GlobalTracer
stores a mutually exclusive Tracer
.
This can then be requested by each thread with GlobalTracer::get
.
Once initialised, the GlobalTracer
cannot be changed or dropped.
Be aware that the GlobalTracer
is backed by a static global variable
so tracers implementing the Drop
traits WILL NOT be dropped.
Examples
extern crate opentracingrust; use opentracingrust::tracers::NoopTracer; use opentracingrust::utils::GlobalTracer; fn main() { let (tracer, _) = NoopTracer::new(); GlobalTracer::init(tracer); let span = GlobalTracer::get().span("root"); }
Methods
impl GlobalTracer
[src]
pub fn init(tracer: Tracer)
[src]
Initialises the GlobalTracer
to store the given Tracer
instance.
Applications should initialise the
GlobalTracer::init
as soon as possible!The
GlobalTracer::init
method is NOT thread safe and MUST be called before any thread is spawned or threads will panic!
Panics
Panics if the GlobalTracer
is already initialised with a Tracer
.
pub fn get() -> MutexGuard<'static, Tracer>
[src]
Exclusively access the singleton Tracer
instance.
Panics
Panics if the singleton Tracer
is requested before the GlobalTracer
is initialised.
Auto Trait Implementations
impl Sync for GlobalTracer
impl Unpin for GlobalTracer
impl Send for GlobalTracer
impl UnwindSafe for GlobalTracer
impl RefUnwindSafe for GlobalTracer
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,