Skip to content

[SDK] MeterProvider: do not warn in destructor after explicit Shutdown - #4085

Merged
marcalff merged 12 commits into
open-telemetry:mainfrom
jaehyeong-cho:mp-shutdown-no-warning
May 19, 2026
Merged

marcalff merged 12 commits into
open-telemetry:mainfrom
jaehyeong-cho:mp-shutdown-no-warning

Conversation

@jaehyeong-cho

@jaehyeong-cho jaehyeong-cho commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3511

Changes

Please provide a brief description of the changes here.

  • Add test ensuring duplicate MeterProvider shutdown emits no log
  • Modify MeterProvider to call context shutdown only once

It seems natural for MeterProvider to shut its context down from the destructor, and since MeterContext is a shared object, I think it is meaningful to warn about duplicate Shutdown calls.
However, I think it may not be a good experience that any user who calls the public MeterProvider::Shutdown API will always receive a warning log afterwards, because this isn't really a misuse case.
Therefore, with this PR, I would like to propose limiting MeterProvider to invoking the context shutdown at most once, so that no warning is emitted in the normal usage path.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@jaehyeong-cho
jaehyeong-cho requested a review from a team as a code owner May 15, 2026 04:36
@codecov

codecov Bot commented May 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.99%. Comparing base (026af08) to head (b08b892).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4085      +/-   ##
==========================================
- Coverage   81.99%   81.99%   -0.00%     
==========================================
  Files         385      385              
  Lines       16023    16025       +2     
==========================================
+ Hits        13137    13138       +1     
- Misses       2886     2887       +1     
Files with missing lines Coverage Δ
sdk/src/metrics/meter_provider.cc 80.77% <100.00%> (+0.77%) ⬆️

... and 1 file with indirect coverage changes

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

@lalitb lalitb left a comment

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.

thanks.

Comment thread sdk/src/metrics/meter_provider.cc Resolved
@jaehyeong-cho
jaehyeong-cho requested a review from ThomsonTan May 18, 2026 03:40
@jaehyeong-cho
jaehyeong-cho force-pushed the mp-shutdown-no-warning branch from c533977 to 3417174 Compare May 18, 2026 22:47
@marcalff
marcalff merged commit a6c8ec8 into open-telemetry:main May 19, 2026
70 checks passed
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.

Cannot Shutdown() MeterProvider manually without a warning from destructor

4 participants