Skip to content

Capture context class loader during async callback registration#8091

Open
trask wants to merge 1 commit intoopen-telemetry:mainfrom
trask:metric-callback-context-class-loader
Open

Capture context class loader during async callback registration#8091
trask wants to merge 1 commit intoopen-telemetry:mainfrom
trask:metric-callback-context-class-loader

Conversation

@trask
Copy link
Member

@trask trask commented Feb 15, 2026

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
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
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.22%. Comparing base (c45930b) to head (2363b37).

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

1 participant