Struct tracing_timing::TimingSubscriber
source · [−]pub struct TimingSubscriber<S = ByName, E = ByMessage> where
S: SpanGroup,
E: EventGroup,
S::Id: Hash + Eq,
E::Id: Hash + Eq, { /* private fields */ }
Expand description
Timing-gathering tracing subscriber.
This type is constructed using a Builder
.
See the crate-level docs for details.
Implementations
sourceimpl<S, E> TimingSubscriber<S, E> where
S: SpanGroup,
E: EventGroup,
S::Id: Hash + Eq,
E::Id: Hash + Eq,
impl<S, E> TimingSubscriber<S, E> where
S: SpanGroup,
E: EventGroup,
S::Id: Hash + Eq,
E::Id: Hash + Eq,
sourcepub fn force_synchronize(&self)
pub fn force_synchronize(&self)
Force all current timing information to be refreshed immediately.
Note that this will interrupt all concurrent metrics gathering until it returns.
sourcepub fn with_histograms<F, R>(&self, f: F) -> R where
F: FnOnce(&mut HashMap<S::Id, IndexMap<E::Id, SyncHistogram<u64>, Hasher>>) -> R,
pub fn with_histograms<F, R>(&self, f: F) -> R where
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
or force_synchronize
to gather up-to-date samples.
For information about what you can do with the histograms, see the hdrhistogram
documentation.
sourceimpl<S, E> TimingSubscriber<S, E> where
S: SpanGroup,
E: EventGroup,
S::Id: Clone + Hash + Eq,
E::Id: Clone + Hash + Eq,
impl<S, E> TimingSubscriber<S, E> where
S: SpanGroup,
E: EventGroup,
S::Id: Clone + Hash + Eq,
E::Id: Clone + Hash + Eq,
sourcepub fn downcaster(&self) -> Downcaster<S, E>
pub fn downcaster(&self) -> Downcaster<S, E>
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
sourceimpl<S, E> Debug for TimingSubscriber<S, E> where
S: SpanGroup + Debug,
S::Id: Hash + Eq + Debug,
E: EventGroup + Debug,
E::Id: Hash + Eq + Debug,
impl<S, E> Debug for TimingSubscriber<S, E> where
S: SpanGroup + Debug,
S::Id: Hash + Eq + Debug,
E: EventGroup + Debug,
E::Id: Hash + Eq + Debug,
sourceimpl<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,
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,
sourcefn new_span(&self, span: &Attributes<'_>) -> Id
fn new_span(&self, span: &Attributes<'_>) -> Id
sourcefn record_follows_from(&self, span: &Id, follows: &Id)
fn record_follows_from(&self, span: &Id, follows: &Id)
Adds an indication that span
follows from the span with the id
follows
. Read more
sourcefn clone_span(&self, span: &Id) -> Id
fn clone_span(&self, span: &Id) -> Id
sourcefn current_span(&self) -> Current
fn current_span(&self) -> Current
Returns a type representing this subscriber’s view of the current span. Read more
sourcefn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Registers a new callsite with this subscriber, returning whether or not the subscriber is interested in being notified about the callsite. Read more
sourcefn max_level_hint(&self) -> Option<LevelFilter>
fn max_level_hint(&self) -> Option<LevelFilter>
Returns the highest verbosity level that this Subscriber
will
enable, or None
, if the subscriber does not implement level-based
filtering or chooses not to implement this method. Read more
Auto Trait Implementations
impl<S, E> RefUnwindSafe for TimingSubscriber<S, E> where
E: RefUnwindSafe,
S: RefUnwindSafe,
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> 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> Unpin for TimingSubscriber<S, E> where
E: Unpin,
S: Unpin,
<E as EventGroup>::Id: Unpin,
<S as SpanGroup>::Id: Unpin,
impl<S, E> UnwindSafe for TimingSubscriber<S, E> where
E: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<S> SubscriberExt for S where
S: Subscriber,
impl<S> SubscriberExt for S where
S: Subscriber,
sourceimpl<T> SubscriberInitExt for T where
T: Into<Dispatch>,
impl<T> SubscriberInitExt for T where
T: Into<Dispatch>,
sourcefn set_default(self) -> DefaultGuard
fn set_default(self) -> DefaultGuard
Sets self
as the default subscriber in the current scope, returning a
guard that will unset it when dropped. Read more
sourcefn try_init(self) -> Result<(), TryInitError>
fn try_init(self) -> Result<(), TryInitError>
Attempts to set self
as the global default subscriber in the current
scope, returning an error if one is already set. Read more
sourcefn init(self)
fn init(self)
Attempts to set self
as the global default subscriber in the current
scope, panicking if this fails. Read more