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

Fix the example installing OpenTelemetryLayer into a global subscriber #175

Open
wants to merge 4 commits into
base: v0.1.x
Choose a base branch
from

Conversation

mzabaluev
Copy link
Contributor

@mzabaluev mzabaluev commented Oct 15, 2024

Fixes #159

Motivation

Use of global::shutdown_tracer_provider has regressed since opentelemetry 0.23.

Solution

Change the opentelemtry-otlp example to call shutdown on the TracingProvider available in scope.

Also added an integration test to verify the export behavior is as expected.

Shutting down the tracer provider via the opentelemetry::global API
has not worked since opentelemetry 0.24 when the batch processor
is in use: buffered traces were not exported. It's not necessary
to install the global provider for the tracing integration, as tracing
has its own way to manage the global subscriber.
Instead, manage the instance in the scope guard the same way as the
meter provider instance, and call the shutdown method on it when the
guard is dropped.
Make sure that an SDK TracerProvider set up with a batch exporter
flushes all buffered spans on shutdown.
In the opentelemetry-otlp example, add a comment explaining how
filtering should prevent reentrancy into the globally installed
tracing layer from the opentelemetry stack where any dependencies
might themselves use tracing.
@djc
Copy link
Collaborator

djc commented Oct 15, 2024

Use of the global::shutdown_tracer_provider has regressed since opentelemetry 0.23.

Have you discussed this regression upstream?

@mzabaluev
Copy link
Contributor Author

Have you discussed this regression upstream?

It has been discussed in open-telemetry/opentelemetry-rust#1961.

This illustrates the problem with opentelemetry::global
that prevents proper use of the batched TracerProvider when installed
as the global provider, flushing it at the end of the program
also with the global API.
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 this pull request may close these issues.

Adding tracing_opentelemetry::layer to tracing_subscriber::registry breaks span exporting to Jaeger
2 participants