Is there a way to force_flush() metrics via the otlp exporter?
Hi,
I have a short lived process and I want to make sure metrics are pushed before it exits. I have setup short intervals and added a sleep before it exits but ideally, I would want to be able to force_flush() the metrics before exiting. Is this currently possible?
Possible related reference: https://opentelemetry.io/docs/reference/specification/metrics/sdk/#forceflush
I was wondering the same. In the Quickstart example, would dropping the otlp_exporter (at the end of main) block the process until metrics are sent or lose metrics (as the process ends without waiting for the metrics to be sent)?
The drop code looks like it would just lose metrics.
I think the big upside of using an exporter (instead of being scraped by prometheus etc.) is the ability to flush metrics during shutdown, so how can we fix that?
Reading the examples, it seems the way to achieve this is to call BasicController.stop().
However that is hard to discover, as the opentelemetry_otlp::OtlpMetricPipeline.build() returns a Result<BasicController> but you cannot click on it because it is not publicly exported.
Would you accept a PR that re-exports BasicController and adjusts the Readme to call BasicController.stop() and global::shutdown_tracer_provider()?
I'm confused by this as well.. it seems there used to be a global::force_flush_tracer_provider() function.. but now it has been removed... I'm not sure what was meant to replace it.
My use-case is for an aws lambda... it sleeps after a run, so unless I send out the traces before it sleeps, I may or may not get any results on the next call.
https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/examples/basic-otlp/src/main.rs#L139 shows an example to shutdown. same approach can be used for force_flush.