Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow overlapping context scopes #2378

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bantonsson
Copy link
Contributor

Fixes #1887

This PR is fully functional, but not complete with edge case checks, tests and comments. It's ment as a basis for discussions.

Changes

This PR changes the single current Context to a more robust stack that is resilient to out of order and overlapping Context scopes. This robustness is needed to be able to support better interop with tokio-rs/tracing.

There are some context_attach benchmarks added, and this implementation performs the same or between 3-17% faster than the old one (while maintaining a working context state).

As for the context benchmarks in opentelemetry-sdk, this implementation performs the same except for the context/is_sampled/?/alt variants where it is 6-7% slower. I haven't dug into this too much at this point.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@bantonsson bantonsson requested a review from a team as a code owner December 3, 2024 12:59
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 96.20253% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.5%. Comparing base (506a4f9) to head (dd46520).

Files with missing lines Patch % Lines
opentelemetry/src/context.rs 96.2% 3 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2378   +/-   ##
=====================================
  Coverage   79.5%   79.5%           
=====================================
  Files        123     123           
  Lines      21479   21551   +72     
=====================================
+ Hits       17084   17149   +65     
- Misses      4395    4402    +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

[Bug]: Overlapping contexts
1 participant