I have an app that's built around tokio
and has async code everywhere. Now I'm trying to instrument the app and add opentelemetry
support - opentelemetry - crates.io: Rust Package Registry.
Sample form opentelemetry crate's README.
use opentelemetry::{global, sdk::export::trace::stdout, trace::Tracer};
fn main() {
// Create a new trace pipeline that prints to stdout
let tracer = stdout::new_pipeline().install_simple();
tracer.in_span("doing_work", |cx| {
// Traced app logic here...
});
// Shutdown trace pipeline
global::shutdown_tracer_provider();
}
It looks like tracer.in_span(...)
takes a closure, and Rust async closures haven't been stabilized yet. So I'm not very sure how to proceed.