fix: return current context in on_end instead of causing panic#3262
fix: return current context in on_end instead of causing panic#3262taisho6339 wants to merge 6 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3262 +/- ##
=======================================
- Coverage 80.9% 80.9% -0.1%
=======================================
Files 129 129
Lines 23756 23765 +9
=======================================
+ Hits 19221 19227 +6
- Misses 4535 4538 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bantonsson
left a comment
There was a problem hiding this comment.
Hi @taisho6339 and thank you for the PR. I have a few comments about the doc and solution.
I will close and reopen the PR to try to start our CI benchmarks.
|
Closing and reopening to start benchmarks. |
97ad7e6 to
14b0e1b
Compare
|
Thank you @taisho6339. The Benchmark numbers look way better now (actually resulting in some benchmarks running faster). I don't see exactly these changes on my MBP M4 Max, but a degradation between 2 and 8 percent which is totally acceptable.
|
bantonsson
left a comment
There was a problem hiding this comment.
Looks good apart from the comment in the tests.
|
This needs a second review and merge @open-telemetry/rust-maintainers |
|
I think this is good to be merged @cijothomas |
762bca8 to
4e5e642
Compare
|
Could you please review when you have the time @cijothomas |
Fixes #2871
Problem
Context::current() panicked with "RefCell already mutably borrowed" when called from SpanProcessor::on_end during span cleanup. Root cause: ContextGuard::drop held a mutable borrow while dropping the context, which triggered Span::drop → on_end → Context::current() → panic.
Solution
Modified ContextGuard::drop to extract the context outside the borrow_mut() scope before dropping it:
Changes
Note
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes