Skip to content

Commit a9b4f1f

Browse files
ref: Stop returning StreamedSpan from get_start_span_function() (#6560)
The new `traces.start_span()` API automatically promotes spans to segment spans if there is no active segment. Since `get_start_span_function()` is never invoked when span streaming is enabled, the function does not need to support the streaming trace lifecycle.
1 parent 4235883 commit a9b4f1f

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

sentry_sdk/ai/utils.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import sentry_sdk
1515
from sentry_sdk.traces import StreamedSpan
16-
from sentry_sdk.tracing_utils import has_span_streaming_enabled
1716
from sentry_sdk.utils import logger
1817

1918
MAX_GEN_AI_MESSAGE_BYTES = 20_000 # 20KB
@@ -538,13 +537,7 @@ def normalize_message_roles(messages: "list[dict[str, Any]]") -> "list[dict[str,
538537

539538

540539
def get_start_span_function() -> "Callable[..., Any]":
541-
if has_span_streaming_enabled(sentry_sdk.get_client().options):
542-
return sentry_sdk.traces.start_span
543-
544540
current_span = sentry_sdk.get_current_span()
545-
if isinstance(current_span, StreamedSpan):
546-
# mypy
547-
return sentry_sdk.traces.start_span
548541

549542
transaction_exists = (
550543
current_span is not None and current_span.containing_transaction is not None

0 commit comments

Comments
 (0)