Skip to content

Use failExceptionally in PeriodicMetricReader when exporter is busy#8525

Merged
jack-berg merged 16 commits into
open-telemetry:mainfrom
vivekp14:main
Jun 25, 2026
Merged

Use failExceptionally in PeriodicMetricReader when exporter is busy#8525
jack-berg merged 16 commits into
open-telemetry:mainfrom
vivekp14:main

Conversation

@vivekp14

Copy link
Copy Markdown
Contributor

Fixes #8433

When forceFlush() is called while a periodic export is already in
progress, PeriodicMetricReader was silently failing with plain fail().

Updated to use failExceptionally(IllegalStateException) so callers
can inspect the cause via CompletableResultCode#getFailureThrowable().

Also added JavaDoc to forceFlush() documenting this edge case.

@vivekp14 vivekp14 requested a review from a team as a code owner June 23, 2026 09:55
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 23, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: vivekp14 / name: vivekp14 (d4511d3)

@kropptrevor

Copy link
Copy Markdown

As it says next to the spotless violations:

Run './gradlew spotlessApply' to fix all violations.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.94%. Comparing base (104d56e) to head (2bc10e3).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8525      +/-   ##
============================================
+ Coverage     90.93%   90.94%   +0.01%     
  Complexity    10209    10209              
============================================
  Files          1013     1013              
  Lines         27175    27175              
  Branches       3184     3184              
============================================
+ Hits          24712    24715       +3     
+ Misses         1735     1733       -2     
+ Partials        728      727       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vivekp14

Copy link
Copy Markdown
Contributor Author

Build is now passing. I noticed the patch coverage is at 50% — happy to add a test covering the forceFlush failure path if that would help get this merged.

@kropptrevor

Copy link
Copy Markdown

@vivekp14 Yes, please add/modify tests. Make sure to test the tests by breaking it to see the test fail.

} else {
result.fail();
result.failExceptionally(
new IllegalStateException("Exporter busy. Dropping metrics."));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh I don't love the "Dropping metrics" because its its not true - metrics are actively being exported! I know you're just continuing the existing text used in the log, but now that its an exception that callers might key off of I want to improve the language. Maybe something like: "Export is already in progress, skipping flush". Would want to update the log line on 295 to match.

Also, extract this message to a constant so it can be used across this exception, the one line line 296, and the log line on 295.

@jack-berg jack-berg merged commit 51fc821 into open-telemetry:main Jun 25, 2026
28 checks passed
@otelbot

otelbot Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @vivekp14! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Force flush conflicts with periodic background exporting

3 participants