-
Bug ReportI like to put logging/tracing code in a separate Version
PlatformLinux david-main 5.11.0-31-generic #33-Ubuntu SMP Wed Aug 11 13:19:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Cratestracing-opentelemetry DescriptionI made a minimal example to illustrate the issue: https://github.com/dskleingeld/tracing-min-exampl/blob/main/src/main.rs When you run this the fmt subscriber prints to stdout: "hello from setup" and "hello main after setup ran". The opentelemetry tracer prints span data once containing only "hello from setup".
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@dskleingeld what is happening in this case is that the after setup root span is not being dropped until the program exists so it is never reported to opentelemetry. You can see the results you are expecting if drop the span earlier: fn main() {
println!("Hello, world!");
setup_tracing();
{
let root = span!(tracing::Level::INFO, "after setup");
let _enter = root.enter();
info!("hello from main after setup ran");
}
opentelemetry::global::shutdown_tracer_provider(); // sending remaining spans
} output:
|
Beta Was this translation helpful? Give feedback.
@dskleingeld what is happening in this case is that the after setup root span is not being dropped until the program exists so it is never reported to opentelemetry.
You can see the results you are expecting if drop the span earlier:
output: