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
[Bug]: TracerProvider::force_flush moved from API to SDK without any way to downcast GlobalTracerProvider #1423
Comments
https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/tracing-jaeger/src/main.rs#L46 Could you see if this is what you are looking for? |
@cijothomas: Thanks for the quick reply! The use case here is FaaS/"serverless" (e.g., AWS Lambda). Specifically, we need a way to flush traces after a request completes, but before AWS Lambda freezes the container to wait for the next request (which may never come, in which case unflushed traces are lost). Prior to the 0.18 release, I would have called Shutting down and registering a new tracing provider for each request seems like it would introduce a lot of unnecessary overhead, when we just need access to the |
Also, I'm willing to contribute a PR to get this done once there's consensus on the API changes. |
@ramosbugs how/where is the tracer provider being created in this case? |
I'm using the following code when the Lambda process starts (i.e., from let batch = BatchSpanProcessor::builder(exporter, opentelemetry::runtime::Tokio)
.with_max_queue_size(MAX_SPAN_QUEUE_SIZE)
.build();
let provider = TracerProvider::builder()
.with_span_processor(batch)
.with_config(tracer_config)
.build();
opentelemetry::global::set_tracer_provider(provider); |
One possible solution is to I don't see anything that requires a mutable reference to the provider, so an |
|
Oh, I totally missed that! Thank you, I will confirm that this works and then close the issue or report back otherwise. |
Cloning the provider before passing it to |
What happened?
PR #658 (issue #588) moved the
force_flush
function from theopentelemetry::trace::TracerProvider
trait to theopentelemetry_sdk::trace::TracerProvider
struct. However, there does not appear to be any API to downcast theGlobalTracerProvider
toopentelemetry_sdk::trace::TracerProvider
.Prior to the 0.18.0 release, it was possible to do the following:
Since
opentelemetry::global::set_tracer_provider
takes ownership of the provider, I don't think there is any way to actually call this function with the current public API.cc: @rohithv1997 @TommyCpp @jtescher
API Version
0.18.0
SDK Version
0.18.0
What Exporters are you seeing the problem on?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: