#[main]Expand description
Instrument an async main function with dial9 telemetry.
This macro is a replacement for #[tokio::main], not a complement —
do not use both attributes on the same function. It builds the Tokio
runtime internally and wraps the function body in a spawned task so that
poll events are recorded by dial9. Without this, code running directly in
runtime.block_on(...) is invisible to the telemetry hooks.
To spawn sub-tasks with wake-event tracking from anywhere inside the
body, call TelemetryHandle::current() — the handle is installed on
every runtime-owned thread by on_thread_start.
§Arguments
config— path to a zero-argument function returning [Dial9Config]. Build one with [Dial9ConfigBuilder::new] (telemetry enabled) or [Dial9ConfigBuilder::disabled] (plain tokio, no telemetry).
§Example
ⓘ
use dial9_tokio_telemetry::{main, config::{Dial9Config, Dial9ConfigBuilder}, telemetry::TelemetryHandle};
fn my_config() -> Dial9Config {
Dial9ConfigBuilder::new("/tmp/trace.bin", 1024 * 1024, 16 * 1024 * 1024)
.build()
}
#[dial9_tokio_telemetry::main(config = my_config)]
async fn main() {
let handle = TelemetryHandle::current();
handle
.spawn(async { /* instrumented sub-task */ })
.await
.unwrap();
}