pub struct TimingSubscriber<S = ByName, E = ByMessage>{ /* private fields */ }
Expand description
Timing-gathering tracing subscriber.
This type is constructed using a Builder
.
See the crate-level docs for details.
Implementations§
Source§impl<S, E> TimingSubscriber<S, E>
impl<S, E> TimingSubscriber<S, E>
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
pub fn with_histograms<F, R>(&self, f: F) -> 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.
Source§impl<S, E> TimingSubscriber<S, E>
impl<S, E> TimingSubscriber<S, E>
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§
Source§impl<S, E> Debug for TimingSubscriber<S, E>
impl<S, E> Debug for TimingSubscriber<S, E>
Source§impl<S, E> Subscriber for TimingSubscriber<S, E>
impl<S, E> Subscriber for TimingSubscriber<S, E>
Source§fn new_span(&self, span: &Attributes<'_>) -> Id
fn new_span(&self, span: &Attributes<'_>) -> Id
Source§fn record_follows_from(&self, span: &Id, follows: &Id)
fn record_follows_from(&self, span: &Id, follows: &Id)
Source§fn clone_span(&self, span: &Id) -> Id
fn clone_span(&self, span: &Id) -> Id
Source§fn current_span(&self) -> Current
fn current_span(&self) -> Current
Source§fn on_register_dispatch(&self, subscriber: &Dispatch)
fn on_register_dispatch(&self, subscriber: &Dispatch)
Source§fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Source§fn max_level_hint(&self) -> Option<LevelFilter>
fn max_level_hint(&self) -> Option<LevelFilter>
Subscriber
will
enable, or None
, if the subscriber does not implement level-based
filtering or chooses not to implement this method. Read moreSource§fn event_enabled(&self, event: &Event<'_>) -> bool
fn event_enabled(&self, event: &Event<'_>) -> bool
Auto Trait Implementations§
impl<S = ByName, E = ByMessage> !Freeze for TimingSubscriber<S, E>
impl<S, E> RefUnwindSafe for TimingSubscriber<S, E>where
S: RefUnwindSafe,
E: RefUnwindSafe,
impl<S, E> Send for TimingSubscriber<S, E>
impl<S, E> Sync for TimingSubscriber<S, E>
impl<S, E> Unpin for TimingSubscriber<S, E>
impl<S, E> UnwindSafe for TimingSubscriber<S, E>where
S: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SubscriberInitExt for T
impl<T> SubscriberInitExt for T
Source§fn set_default(self) -> DefaultGuard
fn set_default(self) -> DefaultGuard
self
as the default subscriber in the current scope, returning a
guard that will unset it when dropped. Read moreSource§fn try_init(self) -> Result<(), TryInitError>
fn try_init(self) -> Result<(), TryInitError>
self
as the global default subscriber in the current
scope, returning an error if one is already set. Read moreSource§fn init(self)
fn init(self)
self
as the global default subscriber in the current
scope, panicking if this fails. Read more