[][src]Struct tracing_timing::TimingSubscriber

pub struct TimingSubscriber<S = ByName, E = ByMessage> where
    S: SpanGroup,
    E: EventGroup,
    S::Id: Hash + Eq,
    E::Id: Hash + Eq
{ /* fields omitted */ }

Timing-gathering tracing subscriber.

This type is constructed using a Builder.

See the crate-level docs for details.

Methods

impl<S, E> TimingSubscriber<S, E> where
    S: SpanGroup,
    E: EventGroup,
    S::Id: Clone + Hash + Eq,
    E::Id: Clone + Hash + Eq
[src]

pub fn force_synchronize(&self)[src]

Force all current timing information to be refreshed immediately.

Note that this will interrupt all concurrent metrics gathering until it returns.

pub fn with_histograms<F, R>(&self, f: F) -> R where
    F: FnOnce(&mut HashMap<S::Id, IndexMap<E::Id, SyncHistogram<u64>, Hasher>>) -> R, 
[src]

Access the timing histograms.

Be aware that the contained histograms are not automatically updated to reflect recently gathered samples. For each histogram you wish to read from, you must call refresh or refresh_timeout to gather up-to-date samples.

For information about what you can do with the histograms, see the hdrhistogram documentation.

impl<S, E> TimingSubscriber<S, E> where
    S: SpanGroup,
    E: EventGroup,
    S::Id: Clone + Hash + Eq,
    E::Id: Clone + Hash + Eq
[src]

pub fn downcaster(&self) -> Downcaster<S, E>[src]

Returns an identifier that can later be used to get access to this TimingSubscriber after it has been turned into a tracing::Dispatch.

use tracing::*;
use tracing_timing::{Builder, Histogram, TimingSubscriber};
let subscriber = Builder::default().build(|| Histogram::new_with_max(1_000_000, 2).unwrap());
let downcaster = subscriber.downcaster();
let dispatch = Dispatch::new(subscriber);
// ...
// code that hands off clones of the dispatch
// maybe to other threads
// ...
downcaster.downcast(&dispatch).unwrap().with_histograms(|hs| {
    for (span_group, hs) in hs {
        for (event_group, h) in hs {
            // make sure we see the latest samples:
            h.refresh();
            // print the median:
            println!("{} -> {}: {}ns", span_group, event_group, h.value_at_quantile(0.5))
        }
    }
});

Trait Implementations

impl<S, E> Debug for TimingSubscriber<S, E> where
    S: SpanGroup + Debug,
    E: EventGroup + Debug,
    S::Id: Hash + Eq + Debug,
    E::Id: Hash + Eq + Debug
[src]

impl<S, E> Subscriber for TimingSubscriber<S, E> where
    S: SpanGroup + 'static,
    E: EventGroup + 'static,
    S::Id: Clone + Hash + Eq + 'static,
    E::Id: Clone + Hash + Eq + 'static, 
[src]

fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest[src]

Registers a new callsite with this subscriber, returning whether or not the subscriber is interested in being notified about the callsite. Read more

fn drop_span(&self, _id: Id)[src]

Deprecated since 0.1.2:

use Subscriber::try_close instead

This method is soft-deprecated. Read more

unsafe fn downcast_raw(&self, id: TypeId) -> Option<*const ()>[src]

If self is the same type as the provided TypeId, returns an untyped *const pointer to that type. Otherwise, returns None. Read more

Auto Trait Implementations

impl<S, E> Send for TimingSubscriber<S, E> where
    E: Send,
    S: Send,
    <E as EventGroup>::Id: Send,
    <S as SpanGroup>::Id: Send

impl<S, E> Unpin for TimingSubscriber<S, E> where
    E: Unpin,
    S: Unpin,
    <E as EventGroup>::Id: Unpin,
    <S as SpanGroup>::Id: Unpin

impl<S, E> Sync for TimingSubscriber<S, E> where
    E: Sync,
    S: Sync,
    <E as EventGroup>::Id: Send + Sync,
    <S as SpanGroup>::Id: Send + Sync

impl<S, E> UnwindSafe for TimingSubscriber<S, E> where
    E: UnwindSafe,
    S: UnwindSafe

impl<S, E> RefUnwindSafe for TimingSubscriber<S, E> where
    E: RefUnwindSafe,
    S: RefUnwindSafe

Blanket Implementations

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<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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