Open biryukovmaxim opened 4 months ago
I also encountered this problem.The provider is dropped after the call to init_tracing is completed, which results in the loss of the weak reference. Extending the lifetime of the provider should resolve the issue.
It might be this issue:
You need to explicitly shutdown metrics
and tracing
before tokio runtime is shutdown.
Basically what happens is that once you register them, they are assigned to global static variable, which is destroyed after you exit from main function.
Metrics and tracing has shutdown functions in order to flush the state before exiting.
If I'm correct, then adding these lines at the end of main function should solve your issue :)
global::shutdown_tracer_provider();
// reset meter provider, so the real thing would shutdown
global::set_meter_provider(NoopMeterProvider::default());
What happened?
Code works with deps:
when I up deps to:
every call produces error:
OpenTelemetry metrics error occurred. Metrics error: reader is shut down or not registered
API Version
0.23.0, 0.22.0
SDK Version
0.23.0, 0.22.1
What Exporter(s) are you seeing the problem on?
Prometheus
Relevant log output