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

Force all current timing information to be refreshed immediately.

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

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.

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

Formats the value using the given formatter. Read more

Returns true if a span or event with the specified metadata would be recorded. Read more

Visit the construction of a new span, returning a new span ID for the span being constructed. Read more

Record a set of values on a span. Read more

Adds an indication that span follows from the span with the id follows. Read more

Records that an Event has occurred. Read more

Records that a span has been entered. Read more

Records that a span has been exited. Read more

Notifies the subscriber that a span ID has been cloned. Read more

Notifies the subscriber that a span ID has been dropped, and returns true if there are now 0 IDs that refer to that span. Read more

Returns a type representing this subscriber’s view of the current span. Read more

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

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

👎 Deprecated since 0.1.2:

use Subscriber::try_close instead

This method is deprecated. Read more

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Wraps self with the provided layer.

Sets self as the default subscriber in the current scope, returning a guard that will unset it when dropped. Read more

Attempts to set self as the global default subscriber in the current scope, returning an error if one is already set. Read more

Attempts to set self as the global default subscriber in the current scope, panicking if this fails. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.