|
5 | 5 | import sentry_sdk |
6 | 6 | from sentry_sdk.consts import OP |
7 | 7 | 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 |
11 | 8 | from sentry_sdk.transport import AsyncHttpTransport |
12 | 9 | from sentry_sdk.utils import ( |
13 | 10 | event_from_exception, |
|
22 | 19 | except ImportError: |
23 | 20 | raise DidNotEnable("asyncio not available") |
24 | 21 |
|
25 | | -from typing import TYPE_CHECKING, Optional, Union |
| 22 | +from typing import TYPE_CHECKING |
26 | 23 |
|
27 | 24 | if TYPE_CHECKING: |
28 | 25 | from collections.abc import Coroutine |
@@ -149,28 +146,18 @@ async def _task_with_sentry_span_creation() -> "Any": |
149 | 146 | integration = client.get_integration(AsyncioIntegration) |
150 | 147 | task_spans = integration.task_spans if integration else False |
151 | 148 |
|
152 | | - span_ctx: "Optional[Union[StreamedSpan, Span]]" = None |
153 | | - is_span_streaming_enabled = has_span_streaming_enabled(client.options) |
154 | | - |
155 | 149 | 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: |
174 | 161 | try: |
175 | 162 | result = await coro |
176 | 163 | except StopAsyncIteration: |
|
0 commit comments