[][src]Struct opentracingrust::utils::GlobalTracer

pub struct 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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,