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

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::default:

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.

Implementations

Set the mechanism used to divide spans into groups.

See SpanGroup and the group module for details.

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

See EventGroup and the group module for details.

Set the time source to use for time measurements.

By default, a TimingSubscriber will record the time since the last event in any child span:

| span foo
| - event a
| | span bar
| | - event b
| - event c

What time is recorded for event c? The default is t_c - t_b. With no_span_recursion, event c will have t_c - t_a. event b will record the time since the start of span bar.

By default, a TimingSubscriber or TimingLayer won’t record a span closure as an event.

| span foo
| - event a
| | span bar
| | - (bar closed)
| - event c

Without span close events, event c will record t_c - t_a. With span_close_events, event c will record t_c - t_bar_close.

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());

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

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

This is equivalent to [layer], 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 layer = builder.layer_informed(|s: &_, e: &_| Histogram::new(3).unwrap());

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

Trait Implementations

Returns the “default value” for a type. 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

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.