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 77.9%. Comparing base (68af3bb) to head (ab2f259).

Files with missing lines Patch % Lines
opentelemetry/src/context.rs 96.2% 3 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2378   +/-   ##
=====================================
  Coverage   77.9%   77.9%           
=====================================
  Files        123     123           
  Lines      22944   23016   +72     
=====================================
+ Hits       17880   17949   +69     
- Misses      5064    5067    +3     

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

@bantonsson bantonsson force-pushed the ban/explore-context-stack branch from dd46520 to ab2f259 Compare January 21, 2025 12:07
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