-
Notifications
You must be signed in to change notification settings - Fork 835
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
feat(sdk-metrics): PeriodicExportingMetricReader now flushes pending tasks at shutdown #5242
feat(sdk-metrics): PeriodicExportingMetricReader now flushes pending tasks at shutdown #5242
Conversation
…cription, calling forceFlush() this also aligns the behavior with the other signals providers: calling sdk.shutdown() will now flush all pending signals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @macno thanks for working on this 🙂
I think the agreement on open-telemetry/opentelemetry-specification#2983 was on the PeriodicExporingMetricReader
- not the MeterProvider
. Would you mind adapting the code accordingly? 🙂
Hi @pichlermarc thanks for taking time to look at the PR. I'm not sure if I read the same agreement, to me seems like an open point. graph TD;
D@{ shape: procs, label: "metricCollector"}
SDK-- shutdown() ---meterProvider;
meterProvider-- shutdown() ---D
D-- shutdown() ---metricReader
so calling What's the reason to move it to |
The equivalent of While it is true that adding it to I asked here again, but I'm fairly certain that my assumption is correct. 🤔 Some links:
|
Ok, I will proceed as requested |
…ion description, calling forceFlush()
Looks like there are a few tests that rely on the old behavior, we'll need to remove the forceFlush in those:
|
…hutdown()' only after 'meterProvider.forceFlush()' resolves
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5242 +/- ##
==========================================
+ Coverage 94.60% 94.65% +0.05%
==========================================
Files 315 315
Lines 8011 8012 +1
Branches 1617 1617
==========================================
+ Hits 7579 7584 +5
+ Misses 432 428 -4
|
Please also add a changelog entry in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks 🙂
Which problem is this PR solving?
Metric provider behave differently from traces and logs providers during shutdown process, being the only one that does not flush pending tasks.
Although it's not explicitly required (yet) by the specs for metrics and logs as it is for traces, this PR adds flushing metrics on shutdown, with the intent of eliminating a not infrequent confusion and wrong assumption among users.
This way we consistently ensure the flush for all supported signals upon shutdown.
The same approach has already been taken by java and python SDKs.
Short description of the changes
now
MeterProvider#shutdown()
callsMeterProvider#forceFlush()
Type of change
Checklist:
addedupdated