-
Notifications
You must be signed in to change notification settings - Fork 438
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
Collect in PeriodicExportingMetricReader ForceFlush before exporting #1858
Comments
Yes, this is correct. Thanks for raising the issue. Related issues on specs: |
The |
Agreed, thanks for linking the related issues.
Yes, that would cover the scenario perfectly. |
Is your feature request related to a problem?
Consider the scenario where some executable emitting metrics through the
PeriodicExportingMetricReader
is about to exit, but desires to collect and export the last value of anObservableGauge
one more time without waiting for the periodic collect and export.Describe the solution you'd like
When using the
PeriodicExportingMetricReader
, it would be nice ifForceFlush()
collects before exporting.Describe alternatives you've considered
I have a metric that could be a
Counter
, but it gets updated very often and emits too many metric points. Therefore I really want to just collect and export it periodically using anObservableGauge
. I could work around it by using aCounter
and periodically updating that myself, forcing one final update and flush upon exit. However, it seems the behavior I desire is common among other language SDKs as well, so I think it may be desired by others forForceFlush
to follow the behavior seen elsewhere.Additional context
I hope I am not missing anything, but if I understand correctly, in the current implementation, an export is performed but no metrics are collected before exporting.
https://github.com/open-telemetry/opentelemetry-cpp/blob/main/sdk/src/metrics/export/periodic_exporting_metric_reader.cc#L85-L88
Other language SDKs appear to collect before exporting on ForceFlush:
Java: https://javadoc.io/static/io.opentelemetry/opentelemetry-sdk-metrics/1.21.0/io/opentelemetry/sdk/metrics/export/PeriodicMetricReader.html#forceFlush()
Python (see force_flush at the bottom, the superclass force_flush collects first): https://opentelemetry-python.readthedocs.io/en/latest/_modules/opentelemetry/sdk/metrics/_internal/export.html#PeriodicExportingMetricReader.force_flush
The text was updated successfully, but these errors were encountered: