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

Add simple scope management whenever a context is attached #3159

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

Conversation

sl0thentr0py
Copy link
Member

  • create a new otel context _SCOPES_KEY that will hold a tuple of (curent_scope, isolation_scope)
  • the current_scope will always be forked (like on every span creation/context update in practice)
    • note that this is on attach, so not on all copy-on-write context object creation but only on apis such as trace.use_span or tracer.start_as_current_span
    • basically every otel context fork corresponds to our current_scope fork
  • the isolation_scope currently will not be forked
    • these will later be updated, for instance when we update our top level scope apis that fork isolation scope, that will also have a corresponding change in this attach function

@sl0thentr0py sl0thentr0py force-pushed the potel-base branch 2 times, most recently from 16f9341 to 951477f Compare June 25, 2024 15:16
@sl0thentr0py sl0thentr0py force-pushed the neel/potel/initial-scope-management branch from e7cbb59 to 4067732 Compare June 25, 2024 15:17
* create a new otel context `_SCOPES_KEY` that will hold a tuple of
  `(curent_scope, isolation_scope)`
* the `current_scope` will always be forked (like on every span creation/context update in practice)
  * note that this is on `attach`, so not on all copy-on-write context
    object creation but only on apis such as
    [`trace.use_span`](https://github.com/open-telemetry/opentelemetry-python/blob/ba22b165471bde2037620f2c850ab648a849fbc0/opentelemetry-api/src/opentelemetry/trace/__init__.py#L547)
    or [`tracer.start_as_current_span`](https://github.com/open-telemetry/opentelemetry-python/blob/ba22b165471bde2037620f2c850ab648a849fbc0/opentelemetry-api/src/opentelemetry/trace/__init__.py#L329)
  * basically every otel `context` fork corresponds to our `current_scope` fork
* the `isolation_scope` currently will not be forked
  * these will later be updated, for instance when we update our top
    level scope apis that fork isolation scope, that will also have a
    corresponding change in this `attach` function
@sl0thentr0py sl0thentr0py force-pushed the neel/potel/initial-scope-management branch from 4067732 to c523182 Compare June 25, 2024 15:17
@sl0thentr0py sl0thentr0py force-pushed the neel/potel/initial-scope-management branch from 9bfab81 to 436626b Compare June 27, 2024 11:37
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 27.27273% with 8 lines in your changes missing coverage. Please review.

Project coverage is 79.27%. Comparing base (4f9257d) to head (436626b).

Additional details and impacted files
@@              Coverage Diff               @@
##           potel-base    #3159      +/-   ##
==============================================
- Coverage       79.30%   79.27%   -0.04%     
==============================================
  Files             134      134              
  Lines           14248    14255       +7     
  Branches         2989     2990       +1     
==============================================
  Hits            11300    11300              
- Misses           2101     2107       +6     
- Partials          847      848       +1     
Files Coverage Δ
.../integrations/opentelemetry/contextvars_context.py 42.85% <27.27%> (-28.58%) ⬇️

... and 1 file with indirect coverage changes

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.

None yet

1 participant