[][src]Struct tracing_timing::Builder

pub struct Builder<S = ByName, E = ByMessage> { /* fields omitted */ }

Builder for TimingSubscriber instances.

This type implements the builder pattern. It lets you easily configure and construct a new TimingSubscriber subscriber. See the individual methods for details. To start, use [Builder::from]:

use tracing_timing::{Builder, Histogram};
let builder = Builder::default();
let subscriber = builder.build(|| Histogram::new(3).unwrap());

See the various new_* methods on Histogram for how to construct an appropriate histogram in the first place. All samples recorded by the subscriber returned from Builder::build will be recorded into histograms as returned by the provided constructor. You can also construct the histograms based on the span and event group it will be tracking by using Builder::build_informed.

Methods

impl<S, E> Builder<S, E>[src]

pub fn spans<S2>(self, span_group: S2) -> Builder<S2, E>[src]

Set the mechanism used to divide spans into groups.

See SpanGroup and the group module for details.

pub fn events<E2>(self, event_group: E2) -> Builder<S, E2>[src]

Set the mechanism used to divide events into per-span groups.

See EventGroup and the group module for details.

pub fn time(self, time: Clock) -> Builder<S, E>[src]

Set the time source to use for time measurements.

pub fn build_informed<F>(self, new_histogram: F) -> TimingSubscriber<S, E> where
    S: SpanGroup,
    E: EventGroup,
    S::Id: Hash + Eq,
    E::Id: Hash + Eq,
    F: FnMut(&S::Id, &E::Id) -> Histogram<u64> + Send + Sync + 'static, 
[src]

Construct a TimingSubscriber that uses the given function to construct new histograms.

This is equivalent to [build], except that the passed function is also told which span/event group the histogram is for.

Note that you may run into weird lifetime errors from the compiler when using this method with a closure. This is a known compiler issue. You can work around it by adding a slight type hint to the arguments passed to the closure as follows (note the : &_):

use tracing_timing::{Builder, Histogram};
let builder = Builder::default();
let subscriber = builder.build_informed(|s: &_, e: &_| Histogram::new(3).unwrap());

pub fn build<F>(self, new_histogram: F) -> TimingSubscriber<S, E> where
    S: SpanGroup,
    E: EventGroup,
    S::Id: Hash + Eq,
    E::Id: Hash + Eq,
    F: FnMut() -> Histogram<u64> + Send + Sync + 'static, 
[src]

Construct a TimingSubscriber that uses the given function to construct new histograms.

Trait Implementations

impl Default for Builder<ByName, ByMessage>[src]

Auto Trait Implementations

impl<S, E> Unpin for Builder<S, E> where
    E: Unpin,
    S: Unpin

impl<S, E> Sync for Builder<S, E> where
    E: Sync,
    S: Sync

impl<S, E> Send for Builder<S, E> where
    E: Send,
    S: Send

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

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

Blanket Implementations

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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]