You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix propagate_scope=False in ThreadingIntegration (#4310)
`ThreadingIntegration` can optionally **NOT** propagate scope data to
threads (`propagate_scope=False`). In that case, in POTel we were
wrapping the thread's task in an `isolation_scope()`:
```python
with sentry_sdk.isolation_scope() as scope:
return _run_old_run_func()
```
But as this forks the currently active isolation scope, the thread
effectively gets all scope data from the parent isolation scope -- so
the scope is actually propagated to the thread, even though it shouldn't
be since `propagate_scope=False`.
~We effectively need some way to give the thread a clear isolation scope
instead. In this PR, I'm just clearing the forked iso scope, but I'm not
sure if this is good enough and if something doesn't need to be done on
the OTel side too.~
~Another option would be to set the iso/current scopes to the initial,
empty iso/current scopes instead, before running the thread's target
function.~
UPDATE: we're just instantiating new scopes now
Another change is that in OTel, the spans in the threads, now without a
parent, automatically get promoted to transactions. (On master they'd
just be orphaned spans, so they wouldn't be taken into account at all.)
We probably need to instruct folks to add `only_if_parent` if they don't
want this to happen.
---------
Co-authored-by: Neel Shah <[email protected]>
0 commit comments