Skip to content

Opentelemetry tracer not working as global default #1552

Answered by jtescher
dvdsk asked this question in Q&A
Discussion options

You must be logged in to vote

@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:

Sep 11 20:28:29.069  INFO in setup: hello from setup
Sep 11 20:28:29.070  INFO after setup: hello from main after setup ran
SpanData { span_contex…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hawkw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1527 on September 12, 2021 16:56.