Skip to content

Commit 2e81110

Browse files
.
1 parent 32b8c5a commit 2e81110

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

sentry_sdk/integrations/celery/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,16 @@ def setup_once() -> None:
9898

9999

100100
def _set_status(status: str) -> None:
101+
client = sentry_sdk.get_client()
102+
span_streaming = has_span_streaming_enabled(client.options)
103+
101104
with capture_internal_exceptions():
102105
scope = sentry_sdk.get_current_scope()
103-
if scope.span is not None:
104-
if isinstance(scope.span, Span):
105-
scope.span.set_status(status)
106-
else:
107-
scope.span.status = "ok" if status == "ok" else "error"
106+
107+
if span_streaming and scope.streamed_span is not None:
108+
scope.streamed_span.status = "ok" if status == "ok" else "error"
109+
elif not span_streaming and scope.span is not None:
110+
scope.span.set_status(status)
108111

109112

110113
def _capture_exception(task: "Any", exc_info: "ExcInfo") -> None:

sentry_sdk/integrations/fastapi.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sentry_sdk
66
from sentry_sdk.integrations import DidNotEnable
77
from sentry_sdk.scope import should_send_default_pii
8-
from sentry_sdk.traces import NoOpStreamedSpan, StreamedSpan
8+
from sentry_sdk.traces import NoOpStreamedSpan
99
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TransactionSource
1010
from sentry_sdk.tracing_utils import has_span_streaming_enabled
1111
from sentry_sdk.utils import transaction_from_function
@@ -90,13 +90,15 @@ def _sentry_get_request_handler(*args: "Any", **kwargs: "Any") -> "Any":
9090
@wraps(old_call)
9191
def _sentry_call(*args: "Any", **kwargs: "Any") -> "Any":
9292
current_scope = sentry_sdk.get_current_scope()
93-
current_span = current_scope.span
9493

95-
if isinstance(current_span, StreamedSpan) and not isinstance(
96-
current_span, NoOpStreamedSpan
97-
):
98-
segment = current_span._segment
99-
segment._update_active_thread()
94+
client = sentry_sdk.get_client()
95+
if has_span_streaming_enabled(client.options):
96+
current_span = current_scope.streamed_span
97+
98+
if not isinstance(current_span, NoOpStreamedSpan):
99+
segment = current_span._segment
100+
segment._update_active_thread()
101+
100102
elif current_scope.transaction is not None:
101103
current_scope.transaction.update_active_thread()
102104

0 commit comments

Comments
 (0)