Skip to content

Commit 4ce2167

Browse files
committed
Merge branch 'potel-base' into ivana/potel/determine-lowest-otel-version
2 parents 752dad5 + a7e24d9 commit 4ce2167

File tree

9 files changed

+29
-35
lines changed

9 files changed

+29
-35
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
3434
author = "Sentry Team and Contributors"
3535

36-
release = "2.26.1"
36+
release = "3.0.0"
3737
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3838

3939

sentry_sdk/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from sentry_sdk.scope import Scope
1+
# TODO-neel scope switch
2+
# TODO-neel avoid duplication between api and __init__
3+
from sentry_sdk.opentelemetry.scope import PotelScope as Scope
24
from sentry_sdk.transport import Transport, HttpTransport
35
from sentry_sdk.client import Client
46

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,4 +985,4 @@ def _get_default_options():
985985
del _get_default_options
986986

987987

988-
VERSION = "2.26.1"
988+
VERSION = "3.0.0"

sentry_sdk/integrations/huey.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ def _capture_exception(exc_info):
111111
# type: (ExcInfo) -> None
112112
scope = sentry_sdk.get_current_scope()
113113

114-
if exc_info[0] in HUEY_CONTROL_FLOW_EXCEPTIONS:
115-
scope.root_span.set_status(SPANSTATUS.ABORTED)
116-
return
114+
if scope.root_span is not None:
115+
if exc_info[0] in HUEY_CONTROL_FLOW_EXCEPTIONS:
116+
scope.root_span.set_status(SPANSTATUS.ABORTED)
117+
return
118+
119+
scope.root_span.set_status(SPANSTATUS.INTERNAL_ERROR)
117120

118-
scope.root_span.set_status(SPANSTATUS.INTERNAL_ERROR)
119121
event, hint = event_from_exception(
120122
exc_info,
121123
client_options=sentry_sdk.get_client().options,
@@ -136,8 +138,10 @@ def _sentry_execute(*args, **kwargs):
136138
exc_info = sys.exc_info()
137139
_capture_exception(exc_info)
138140
reraise(*exc_info)
139-
else:
140-
sentry_sdk.get_current_scope().root_span.set_status(SPANSTATUS.OK)
141+
142+
root_span = sentry_sdk.get_current_scope().root_span
143+
if root_span is not None:
144+
root_span.set_status(SPANSTATUS.OK)
141145

142146
return result
143147

sentry_sdk/integrations/threading.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from threading import Thread, current_thread
55

66
import sentry_sdk
7+
from sentry_sdk import Scope
8+
from sentry_sdk.scope import ScopeType
79
from sentry_sdk.integrations import Integration
810
from sentry_sdk.utils import (
911
event_from_exception,
@@ -17,7 +19,6 @@
1719
from typing import Any
1820
from typing import TypeVar
1921
from typing import Callable
20-
from typing import Optional
2122

2223
from sentry_sdk._types import ExcInfo
2324

@@ -75,8 +76,8 @@ def sentry_start(self, *a, **kw):
7576
isolation_scope = sentry_sdk.get_isolation_scope().fork()
7677
current_scope = sentry_sdk.get_current_scope().fork()
7778
else:
78-
isolation_scope = None
79-
current_scope = None
79+
isolation_scope = Scope(ty=ScopeType.ISOLATION)
80+
current_scope = Scope(ty=ScopeType.CURRENT)
8081

8182
# Patching instance methods in `start()` creates a reference cycle if
8283
# done in a naive way. See
@@ -98,7 +99,7 @@ def sentry_start(self, *a, **kw):
9899

99100

100101
def _wrap_run(isolation_scope_to_use, current_scope_to_use, old_run_func):
101-
# type: (Optional[sentry_sdk.Scope], Optional[sentry_sdk.Scope], F) -> F
102+
# type: (sentry_sdk.Scope, sentry_sdk.Scope, F) -> F
102103
@wraps(old_run_func)
103104
def run(*a, **kw):
104105
# type: (*Any, **Any) -> Any
@@ -110,13 +111,8 @@ def _run_old_run_func():
110111
except Exception:
111112
reraise(*_capture_exception())
112113

113-
if isolation_scope_to_use is not None and current_scope_to_use is not None:
114-
with sentry_sdk.use_isolation_scope(isolation_scope_to_use):
115-
with sentry_sdk.use_scope(current_scope_to_use):
116-
return _run_old_run_func()
117-
else:
118-
with sentry_sdk.isolation_scope() as scope:
119-
scope.clear()
114+
with sentry_sdk.use_isolation_scope(isolation_scope_to_use):
115+
with sentry_sdk.use_scope(current_scope_to_use):
120116
return _run_old_run_func()
121117

122118
return run # type: ignore

sentry_sdk/integrations/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class _ScopedResponse:
254254
__slots__ = ("_response", "_scope")
255255

256256
def __init__(self, scope, response):
257-
# type: (sentry_sdk.scope.Scope, Iterator[bytes]) -> None
257+
# type: (sentry_sdk.Scope, Iterator[bytes]) -> None
258258
self._scope = scope
259259
self._response = response
260260

sentry_sdk/opentelemetry/scope.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def setup_scope_context_management():
175175

176176
@contextmanager
177177
def isolation_scope():
178-
# type: () -> Generator[Scope, None, None]
178+
# type: () -> Generator[PotelScope, None, None]
179179
context = set_value(SENTRY_FORK_ISOLATION_SCOPE_KEY, True)
180180
token = attach(context)
181181
try:
@@ -186,7 +186,7 @@ def isolation_scope():
186186

187187
@contextmanager
188188
def new_scope():
189-
# type: () -> Generator[Scope, None, None]
189+
# type: () -> Generator[PotelScope, None, None]
190190
token = attach(get_current())
191191
try:
192192
yield PotelScope.get_current_scope()
@@ -196,7 +196,7 @@ def new_scope():
196196

197197
@contextmanager
198198
def use_scope(scope):
199-
# type: (Scope) -> Generator[Scope, None, None]
199+
# type: (PotelScope) -> Generator[PotelScope, None, None]
200200
context = set_value(SENTRY_USE_CURRENT_SCOPE_KEY, scope)
201201
token = attach(context)
202202

@@ -208,7 +208,7 @@ def use_scope(scope):
208208

209209
@contextmanager
210210
def use_isolation_scope(isolation_scope):
211-
# type: (Scope) -> Generator[Scope, None, None]
211+
# type: (PotelScope) -> Generator[PotelScope, None, None]
212212
context = set_value(SENTRY_USE_ISOLATION_SCOPE_KEY, isolation_scope)
213213
token = attach(context)
214214

sentry_sdk/scope.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -692,19 +692,11 @@ def fingerprint(self, value):
692692

693693
@property
694694
def root_span(self):
695-
# type: () -> Any
696-
# would be type: () -> Optional[Span], see https://github.com/python/mypy/issues/3004
695+
# type: () -> Optional[Span]
697696
"""Return the root span in the scope, if any."""
698-
699-
# there is no span/transaction on the scope
700697
if self._span is None:
701698
return None
702699

703-
# there is an orphan span on the scope
704-
if self._span.root_span is None:
705-
return None
706-
# there is either a root span (which is its own root
707-
# span) or a non-orphan span on the scope
708700
return self._span.root_span
709701

710702
def set_transaction_name(self, name, source=None):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_file_text(file_name):
2121

2222
setup(
2323
name="sentry-sdk",
24-
version="2.26.1",
24+
version="3.0.0",
2525
author="Sentry Team and Contributors",
2626
author_email="[email protected]",
2727
url="https://github.com/getsentry/sentry-python",

0 commit comments

Comments
 (0)