tokio_trace/subscriber.rs
1//! Collects and records trace data.
2pub use tokio_trace_core::subscriber::*;
3
4/// Sets this dispatch as the default for the duration of a closure.
5///
6/// The default dispatcher is used when creating a new [`Span`] or
7/// [`Event`], _if no span is currently executing_. If a span is currently
8/// executing, new spans or events are dispatched to the subscriber that
9/// tagged that span, instead.
10///
11/// [`Span`]: ../span/struct.Span.html
12/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
13/// [`Event`]: :../event/struct.Event.html
14pub fn with_default<T, S>(subscriber: S, f: impl FnOnce() -> T) -> T
15where
16 S: Subscriber + Send + Sync + 'static,
17{
18 ::dispatcher::with_default(&::Dispatch::new(subscriber), f)
19}