Skip to main content

span_async_named

Macro span_async_named 

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

Instruments an async block with a named span using a static string. This creates both the SpanLocation and instruments the future in one macro call.

ยงExamples

use micromegas_tracing::prelude::*;

let result = span_async_named!("database_query", async {
    // async work here
    42
}).await;

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

use micromegas_tracing::prelude::*;

let rows = span_async_named!("database_query", async { vec![1, 2] }, |rows, span| {
    span.set_property("rows", rows.len());
}).await;