Skip to content

Capture context class loader during async callback registration#8091

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
trask:metric-callback-context-class-loader
Mar 16, 2026
Merged

Capture context class loader during async callback registration#8091
jack-berg merged 1 commit into
open-telemetry:mainfrom
trask:metric-callback-context-class-loader

Conversation

@trask

@trask trask commented Feb 15, 2026

Copy link
Copy Markdown
Member

Resolves #5694

Also probably would have avoided the breakage @brunobat reported in #7488 (comment).

private final Runnable callback;
private final List<InstrumentDescriptor> instrumentDescriptors;
private final boolean hasStorages;
@Nullable private final ClassLoader contextClassLoader;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think strong ref to the context class loader here is ok, given that we already have a strong ref to the callback's class loader

could make it a weakref, but not sure there's a foolproof behavior when it gets cleared

@codecov

codecov Bot commented Feb 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.22%. Comparing base (c45930b) to head (2363b37).
⚠️ Report is 70 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8091   +/-   ##
=========================================
  Coverage     90.21%   90.22%           
- Complexity     7605     7606    +1     
=========================================
  Files           841      841           
  Lines         22923    22928    +5     
  Branches       2291     2291           
=========================================
+ Hits          20681    20687    +6     
  Misses         1525     1525           
+ Partials        717      716    -1     

☔ 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.

@trask
trask marked this pull request as ready for review February 15, 2026 00:44
@trask
trask requested a review from a team as a code owner February 15, 2026 00:44

@jack-berg jack-berg 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.

This looks good. Sorry it took me a bit to get to.

Thanks!

@jack-berg
jack-berg merged commit 6edc786 into open-telemetry:main Mar 16, 2026
27 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.

Invoke async metric callbacks in the context class loader from the time when the instrument was registered

2 participants