Trait tracing::instrument::Instrument [−][src]
pub trait Instrument: Sized { fn instrument(self, span: Span) -> Instrumented<Self>ⓘ{ ... } fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T: Future> Future for Instrumented<T> type Output = T::Output;{ ... } }Notable traits for Instrumented<T>
impl<T: Future> Future for Instrumented<T> type Output = T::Output;
Attaches spans to a std::future::Future.
Extension trait allowing futures to be
instrumented with a tracing span.
Provided methods
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T: Future> Future for Instrumented<T> type Output = T::Output;[src]
Notable traits for Instrumented<T>
impl<T: Future> Future for Instrumented<T> type Output = T::Output;Instruments this type with the provided Span, returning an
Instrumented wrapper.
The attached Span will be entered every time the instrumented Future is polled.
Examples
Instrumenting a future:
use tracing::Instrument; let my_future = async { // ... }; my_future .instrument(tracing::info_span!("my_future")) .await
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T: Future> Future for Instrumented<T> type Output = T::Output;[src]
Notable traits for Instrumented<T>
impl<T: Future> Future for Instrumented<T> type Output = T::Output;Instruments this type with the current Span, returning an
Instrumented wrapper.
If the instrumented type is a future, stream, or sink, the attached Span
will be entered every time it is polled. If the instrumented type
is a future executor, every future spawned on that executor will be
instrumented by the attached Span.
This can be used to propagate the current span when spawning a new future.
Examples
use tracing::Instrument; let span = tracing::info_span!("my_span"); let _enter = span.enter(); // ... let future = async { tracing::debug!("this event will occur inside `my_span`"); // ... }; tokio::spawn(future.in_current_span());