Skip to content

Commit 27204fa

Browse files
authored
1 parent edcfc1f commit 27204fa

2 files changed

Lines changed: 152 additions & 343 deletions

File tree

sentry_sdk/integrations/asyncio.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import sentry_sdk
66
from sentry_sdk.consts import OP
77
from sentry_sdk.integrations import DidNotEnable, Integration
8-
from sentry_sdk.traces import StreamedSpan
9-
from sentry_sdk.tracing import Span
10-
from sentry_sdk.tracing_utils import has_span_streaming_enabled
118
from sentry_sdk.transport import AsyncHttpTransport
129
from sentry_sdk.utils import (
1310
event_from_exception,
@@ -22,7 +19,7 @@
2219
except ImportError:
2320
raise DidNotEnable("asyncio not available")
2421

25-
from typing import TYPE_CHECKING, Optional, Union
22+
from typing import TYPE_CHECKING
2623

2724
if TYPE_CHECKING:
2825
from collections.abc import Coroutine
@@ -149,28 +146,18 @@ async def _task_with_sentry_span_creation() -> "Any":
149146
integration = client.get_integration(AsyncioIntegration)
150147
task_spans = integration.task_spans if integration else False
151148

152-
span_ctx: "Optional[Union[StreamedSpan, Span]]" = None
153-
is_span_streaming_enabled = has_span_streaming_enabled(client.options)
154-
155149
with sentry_sdk.isolation_scope():
156-
if task_spans:
157-
if is_span_streaming_enabled:
158-
if sentry_sdk.traces.get_current_span() is not None:
159-
span_ctx = sentry_sdk.traces.start_span(
160-
name=get_name(coro),
161-
attributes={
162-
"sentry.op": OP.FUNCTION,
163-
"sentry.origin": AsyncioIntegration.origin,
164-
},
165-
)
166-
else:
167-
span_ctx = sentry_sdk.start_span(
168-
op=OP.FUNCTION,
169-
name=get_name(coro),
170-
origin=AsyncioIntegration.origin,
171-
)
172-
173-
with span_ctx if span_ctx else nullcontext():
150+
span_ctx = nullcontext()
151+
if task_spans and sentry_sdk.traces.get_current_span() is not None:
152+
span_ctx = sentry_sdk.traces.start_span(
153+
name=get_name(coro),
154+
attributes={
155+
"sentry.op": OP.FUNCTION,
156+
"sentry.origin": AsyncioIntegration.origin,
157+
},
158+
)
159+
160+
with span_ctx:
174161
try:
175162
result = await coro
176163
except StopAsyncIteration:

0 commit comments

Comments
 (0)