[][src]Trait tracing_futures::Instrument

pub trait Instrument: Sized {
    pub fn instrument(self, span: Span) -> Instrumented<Self>

Notable traits for Instrumented<T>

impl<T: Future> Future for Instrumented<T> type Output = T::Output;
{ ... }
pub fn in_current_span(self) -> Instrumented<Self>

Notable traits for Instrumented<T>

impl<T: Future> Future for Instrumented<T> type Output = T::Output;
{ ... } }

Extension trait allowing futures, streams, sinks, and executors to be instrumented with a tracing span.

Provided methods

pub fn instrument(self, span: Span) -> Instrumented<Self>

Notable traits for Instrumented<T>

impl<T: Future> Future for Instrumented<T> type Output = T::Output;
[src]

Instruments this type with the provided 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.

Examples

Instrumenting a future:

use tracing_futures::Instrument;

let my_future = async {
    // ...
};

my_future
    .instrument(tracing::info_span!("my_future"))
    .await

pub fn in_current_span(self) -> Instrumented<Self>

Notable traits for Instrumented<T>

impl<T: Future> Future for Instrumented<T> type Output = T::Output;
[src]

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_futures::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());
Loading content...

Implementors

impl<T: Sized> Instrument for T[src]

Loading content...