[][src]Struct tracing_timing::TimingLayer

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

Timing-gathering tracing layer.

This type is constructed using a Builder.

See the [crate-level docs] for details.

Methods

impl<S, E> TimingLayer<S, E> where
    S: SpanGroup,
    E: EventGroup,
    S::Id: Hash + Eq,
    E::Id: 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> TimingLayer<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 TimingLayer after it has been turned into a tracing::Dispatch.

use tracing::*;
use tracing_timing::{Builder, Histogram, TimingLayer};
use tracing_subscriber::{registry::Registry, Layer};
let layer = Builder::default()
    .layer(|| Histogram::new_with_max(1_000_000, 2).unwrap());
let downcaster = layer.downcaster();
let dispatch = Dispatch::new(layer.with_subscriber(Registry::default()));
// ...
// 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 TimingLayer<S, E> where
    S: SpanGroup + Debug,
    S::Id: Hash + Eq + Debug,
    E: EventGroup + Debug,
    E::Id: Hash + Eq + Debug
[src]

impl<S, SG, EG> Layer<S> for TimingLayer<SG, EG> where
    S: Subscriber + for<'span> LookupSpan<'span>,
    Self: 'static,
    SG: SpanGroup,
    EG: EventGroup,
    SG::Id: Clone + Hash + Eq + Send + Sync,
    EG::Id: Clone + Hash + Eq + Send + Sync
[src]

Auto Trait Implementations

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

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

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

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

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

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.