Skip to main content

InstrumentFuture

Trait InstrumentFuture 

Source
pub trait InstrumentFuture: Sized + Future {
    // Provided methods
    fn instrument(
        self,
        span_desc: &'static SpanMetadata,
    ) -> InstrumentedFuture<Self> ⓘ { ... }
    fn instrument_with<H>(
        self,
        span_desc: &'static SpanMetadata,
        on_end: H,
    ) -> InstrumentedFuture<Self, H> ⓘ
       where H: FnOnce(&Self::Output, &mut SpanProperties) { ... }
}
Expand description

Trait for adding instrumentation to futures

Provided Methods§

Source

fn instrument( self, span_desc: &'static SpanMetadata, ) -> InstrumentedFuture<Self> ⓘ

Instrument this future with the given span metadata

Source

fn instrument_with<H>( self, span_desc: &'static SpanMetadata, on_end: H, ) -> InstrumentedFuture<Self, H> ⓘ
where H: FnOnce(&Self::Output, &mut SpanProperties),

Instruments this future, and lets on_end add properties to the end event from the output. A hook that sets nothing leaves the plain end event.

use micromegas_tracing::prelude::*;
use micromegas_tracing::spans::InstrumentFuture as _;

static_span_desc!(FETCH, "fetch");
let rows = async { vec![1, 2, 3] }
    .instrument_with(&FETCH, |rows, span| span.set_property("rows", rows.len()))
    .await;

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F> InstrumentFuture for F
where F: Future,