Skip to content

fix: LoggingSpanExporter.flush() should preserve flush failures#8361

Merged
jack-berg merged 7 commits intoopen-telemetry:mainfrom
ADITYA-CODE-SOURCE:main
May 8, 2026
Merged

fix: LoggingSpanExporter.flush() should preserve flush failures#8361
jack-berg merged 7 commits intoopen-telemetry:mainfrom
ADITYA-CODE-SOURCE:main

Conversation

@ADITYA-CODE-SOURCE
Copy link
Copy Markdown
Contributor

@ADITYA-CODE-SOURCE ADITYA-CODE-SOURCE commented May 2, 2026

Fixes a bug where LoggingSpanExporter.flush() unconditionally returned success, even if an underlying logger handler failed during flushing. This masked flush failures from the caller.

Changes:

  • narrow the production fix to LoggingSpanExporter.flush() so it returns the failure result from the catch path
  • keep regression coverage for both LoggingSpanExporter and LoggingMetricExporter flush failure behavior
  • isolate the logger-handler-based flush tests so they clean up temporary handlers after each run

Fixes #8360

…urns success

LoggingSpanExporter.flush() and LoggingMetricExporter.flush() unconditionally
return success even if underlying handlers fail. This masks errors from the
caller.

Fixes open-telemetry#8360
@ADITYA-CODE-SOURCE ADITYA-CODE-SOURCE requested a review from a team as a code owner May 2, 2026 11:31
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 2, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.87%. Comparing base (1b207c6) to head (0e034ab).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8361      +/-   ##
============================================
+ Coverage     90.82%   90.87%   +0.05%     
- Complexity     7927     7954      +27     
============================================
  Files           895      896       +1     
  Lines         23872    24010     +138     
  Branches       2378     2390      +12     
============================================
+ Hits          21681    21819     +138     
- Misses         1446     1453       +7     
+ Partials        745      738       -7     

☔ View full report in Codecov by Sentry.
📢 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.

@ADITYA-CODE-SOURCE
Copy link
Copy Markdown
Contributor Author

ADITYA-CODE-SOURCE commented May 7, 2026

@psx95 Thanks for the review. You were right that the production bug is only in LoggingSpanExporter.flush(); I narrowed the code change to that method and reverted the unnecessary production change in LoggingMetricExporter. I kept the failure coverage for both exporters, renamed the flush failure tests to match the existing naming style, and cleaned up the temporary logger/handler setup in the tests.

@ADITYA-CODE-SOURCE ADITYA-CODE-SOURCE changed the title fix: LoggingSpanExporter and LoggingMetricExporter flush() always returns success fix: LoggingSpanExporter.flush() should preserve flush failures May 7, 2026
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure why this file required a change. Could you explain the reasoning behind making this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right — that change was only a CI workaround for an unrelated configuration-cache failure, and it broadened the scope of this PR. I removed it in commit 49a8703 so this PR stays focused on the LoggingSpanExporter fix.

Copy link
Copy Markdown
Contributor

@psx95 psx95 May 7, 2026

Choose a reason for hiding this comment

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

Nit: This file still has a change - a line was removed. This file should not be in the diff for this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There was still a whitespace-only leftover in . I restored it to match exactly in commit 0e034ab, so it should no longer appear in the diff.\n\nCould you please take another look? I believe all requested changes are addressed now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There was still a whitespace-only leftover in integration-tests/graal-incubating/build.gradle.kts. I restored it to match main exactly in commit 0e034ab, so it should no longer appear in the diff.\n\nCould you please take another look? I believe all requested changes are addressed now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that there are two tests in this file relying on the behavior of logger handler, I think it will be better if this test is also updated to remove the logger handler towards the end of the test.

This way both the tests can run in isolation in terms of LoggingHandler behavior.

I think the same would apply for the other test file as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I updated both success-path flush tests in commit 49a8703 to remove the temporary handler in a finally block so the logger state is isolated between tests.

@ADITYA-CODE-SOURCE
Copy link
Copy Markdown
Contributor Author

@psx95 Thanks again for the review. I believe all the requested changes are addressed now the scope is narrowed to LoggingSpanExporter the unrelated graal-incubating change is removed and both flush tests clean up their handlers properly. All checks are passing.
Could you please take another look when you have a chance?

Copy link
Copy Markdown
Contributor

@psx95 psx95 May 7, 2026

Choose a reason for hiding this comment

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

Nit: This file still has a change - a line was removed. This file should not be in the diff for this PR.

@ADITYA-CODE-SOURCE
Copy link
Copy Markdown
Contributor Author

@psx95 Thanks again for the review. The leftover whitespace-only change in is now removed, the PR diff is back to the three intended logging files, and all checks are passing.\n\nCould you please take another look when you have a chance?

Copy link
Copy Markdown
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Thanks, and thanks for the review @psx95

@jack-berg jack-berg merged commit 3351182 into open-telemetry:main May 8, 2026
28 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented May 8, 2026

Thank you for your contribution @ADITYA-CODE-SOURCE! 🎉 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.

LoggingSpanExporter.flush() always returns success masking failures

3 participants