[−][src]Struct tracing_timing::TimingLayer
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]
S: SpanGroup,
E: EventGroup,
S::Id: Hash + Eq,
E::Id: Hash + Eq,
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]
F: FnOnce(&mut HashMap<S::Id, IndexMap<E::Id, SyncHistogram<u64>, Hasher>>) -> R,
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]
S: SpanGroup,
E: EventGroup,
S::Id: Clone + Hash + Eq,
E::Id: Clone + Hash + Eq,
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]
S: SpanGroup + Debug,
S::Id: Hash + Eq + Debug,
E: EventGroup + Debug,
E::Id: Hash + Eq + Debug,
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]
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,
fn new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<S>)
[src]
fn on_event(&self, event: &Event, ctx: Context<S>)
[src]
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
[src]
fn enabled(&self, metadata: &Metadata, ctx: Context<S>) -> bool
[src]
fn on_record(&self, _span: &Id, _values: &Record, _ctx: Context<S>)
[src]
fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<S>)
[src]
fn on_enter(&self, _id: &Id, _ctx: Context<S>)
[src]
fn on_exit(&self, _id: &Id, _ctx: Context<S>)
[src]
fn on_close(&self, _id: Id, _ctx: Context<S>)
[src]
fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<S>)
[src]
fn and_then<L>(self, layer: L) -> Layered<L, Self, S> where
L: Layer<S>,
[src]
L: Layer<S>,
fn with_subscriber(self, inner: S) -> Layered<Self, S, S>
[src]
Auto Trait Implementations
impl<S, E> RefUnwindSafe for TimingLayer<S, E> where
E: RefUnwindSafe,
S: RefUnwindSafe,
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,
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,
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,
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,
E: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,