#[trace]
Expand description
An attribute-macro to help get rid of boilerplate.
trace
always require an local parent in the context. Make sure that the caller
is within the scope of Span::set_local_parent()
.
Examples
use minitrace::prelude::*;
#[trace("foo")]
fn foo() {
// some work
}
#[trace("bar")]
async fn bar() {
// some work
}
#[trace("qux", enter_on_poll = true)]
async fn qux() {
// some work
}
The examples above will be translated into:
fn foo() {
let __guard = LocalSpan::enter_with_local_parent("foo");
// some work
}
fn bar() -> impl core::future::Future<Output = ()> {
async {
// some work
}
.in_span(Span::enter_with_local_parent("bar"))
}
fn qux() -> impl core::future::Future<Output = ()> {
async {
// some work
}
.enter_on_poll("qux")
}