Skip to main content

instrument_named_dyn

Macro instrument_named_dyn 

Source
macro_rules! instrument_named_dyn {
    ($future:expr, $name:expr) => { ... };
    ($future:expr, $name:expr, $on_end:expr) => { ... };
}
Expand description

Instruments a future with a named span whose name is built at runtime. The future owns the name: pass a String or Arc<str> to keep the future 'static. Usage: instrument_named_dyn!(future, format!("op {id}"))

ยงExamples

use micromegas_tracing::prelude::*;

let future = async { 42 };
let result = instrument_named_dyn!(future, format!("operation {}", 1)).await;

A trailing closure receives the output and a &mut SpanProperties to set end properties on:

use micromegas_tracing::prelude::*;

let n = instrument_named_dyn!(async { 42 }, format!("operation {}", 1), |n, span| {
    span.set_property("n", n);
})
.await;