Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking upstream bug #3

Closed
nshalman opened this issue Nov 21, 2024 · 0 comments · Fixed by #4
Closed

Tracking upstream bug #3

nshalman opened this issue Nov 21, 2024 · 0 comments · Fixed by #4

Comments

@nshalman
Copy link
Contributor

nshalman commented Nov 21, 2024

Tracking upstream bug

davidB/tracing-opentelemetry-instrumentation-sdk#184
davidB/tracing-opentelemetry-instrumentation-sdk#185

I believe this to be a consequence of open-telemetry/opentelemetry-rust#1961

Using these versions:

[dependencies]
init-tracing-opentelemetry = { version = "0.19", features = [
  "otlp",
  "tls",
  "tracing_subscriber_ext",
] }
opentelemetry = "0.23"
tokio = { version = "1.38", features = ["full"] }
tracing = "0.1.40"

This code works (I can get a trace):

#[tracing::instrument]
async fn hello() -> () {
    tracing::info!("Hello World!");
}

#[tokio::main]
async fn main() {
    match std::env::var("OTEL_SERVICE_NAME") {
        Ok(_) => (),
        Err(_) => std::env::set_var("OTEL_SERVICE_NAME", "hello"),
    };
    init_tracing_opentelemetry::tracing_subscriber_ext::init_subscribers().expect("Tracing setup");
    hello().await;
    opentelemetry::global::shutdown_tracer_provider();
}

But when I change to these versions, the trace doesn't get emitted:

[dependencies]
init-tracing-opentelemetry = { version = "0.24", features = [
  "otlp",
  "tls",
  "tracing_subscriber_ext",
] }
opentelemetry = "0.27"
tokio = { version = "1.38", features = ["full"] }
tracing = "0.1.40"

With this grossest of workarounds I can get the trace to show up again:

@@ -12,4 +12,5 @@ async fn main() {
     init_tracing_opentelemetry::tracing_subscriber_ext::init_subscribers().expect("Tracing setup");
     hello().await;
     opentelemetry::global::shutdown_tracer_provider();
+    std::thread::sleep(std::time::Duration::from_millis(8000));
 }
nshalman added a commit to nshalman/rust-otel-tools that referenced this issue Nov 25, 2024
This commit brings in init-tracing-openetelemtry 0.24.1
which fixes a bug where spans might not get sent before
program termination.

Updating to this version may require some light code
changes to ensure that the guard struct is being
handled correctly to ensure trace flushing.

Fixes equinix-labs#3

Related:
- davidB/tracing-opentelemetry-instrumentation-sdk#184
- davidB/tracing-opentelemetry-instrumentation-sdk#185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant