-
Notifications
You must be signed in to change notification settings - Fork 523
Nothing exported when I use tracing::subscriber::set_global_default
#2749
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
Comments
From your code, it seems you are not using the latest opentelemetry-* (v0.28.0) and tracing-opentelemetry(v0.29.0) versions. Can you please try with latest versions and update here. Also try with stdout exporter instead of otlp exporter, would be helpful to debug the issue. |
Thank you, however when I do upgrade it breaks my code in several ways. I've been banging my head on this issue for a while now and could use some more specific guidance if you don't mind. If I were to try to write this targeting the latest EDIT: To narrow things down a bit: Say I use the example here. How do I go about setting up a global subscriber? The way I'm doing it above seems incompatible with the example code. Thanks. |
The example in the repo is already setting global subscriber: https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/examples/basic-otlp-http/src/main.rs#L106 // Initialize the tracing subscriber with the OpenTelemetry layer and the
// Fmt layer.
tracing_subscriber::registry()
.with(otel_layer)
.with(fmt_layer)
.init(); |
Thank you, in testing I can see that now. I'll close this issue but this seems counterintuitive for there to be a
which apparently sets the default subscriber but doesn't seem to claim that anywhere in the documentation for that module. What in the documentation should cause me to think this would accomplish what I'm trying to do? Thanks. |
Uh oh!
There was an error while loading. Please reload this page.
Hello.
I'm trying to set the default subscriber for my entire program using
set_global_default
but am not getting the result that I expect. I can useset_default
successfully, and I can use.with_default
in a closure successfully.When I use method 1 or 2 in the code below, my tracing events are sent to my collector, but when I use method 1 (
set_global_default
) nothing is sent to my collector and no error is emitted when I check its state. Any help would be greatly appreciated. Thanks!Someone recently suggested adding a call to the provider's
.shutdown()
which makes sense to me, but that unfortunately makes everything stop working.I have already raised the issue with the
tracing
team as I initially thought the problem was with that, but I think now we know it is not.Any help would be greatly appreciated!
Similar working example
It seems like this example although different from what I'm trying to do does demonstrate that
set_global_default
can work, but why would the subscriber make any difference here? The subscriber clearly works in my original example when I useset_default
.The text was updated successfully, but these errors were encountered: