1111from sentry_sdk .consts import SPANDATA , SPANSTATUS , OP
1212from sentry_sdk .integrations import DidNotEnable
1313from sentry_sdk .scope import should_send_default_pii
14- from sentry_sdk .tracing import Span
1514from sentry_sdk .tracing_utils import set_span_errored
1615from sentry_sdk .utils import event_from_exception , safe_serialize
1716from sentry_sdk .ai ._openai_completions_api import _transform_system_instructions
2322from typing import TYPE_CHECKING
2423
2524if TYPE_CHECKING :
26- from typing import Any , Union
25+ from typing import Any
2726 from agents import Usage , TResponseInputItem
2827
29- from sentry_sdk .traces import StreamedSpan
3028 from sentry_sdk ._types import TextPart
3129
3230try :
@@ -47,26 +45,6 @@ def _capture_exception(exc: "Any") -> None:
4745 sentry_sdk .capture_event (event , hint = hint )
4846
4947
50- def _record_exception_on_span (
51- span : "Union[Span, StreamedSpan]" , error : Exception
52- ) -> "Any" :
53- set_span_errored (span )
54-
55- if not isinstance (span , Span ):
56- # TODO[span-first]: make this work with streamedspans
57- return
58-
59- span .set_data ("span.status" , "error" )
60-
61- # Optionally capture the error details if we have them
62- if hasattr (error , "__class__" ):
63- span .set_data ("error.type" , error .__class__ .__name__ )
64- if hasattr (error , "__str__" ):
65- error_message = str (error )
66- if error_message :
67- span .set_data ("error.message" , error_message )
68-
69-
7048def _set_agent_data (span : "sentry_sdk.tracing.Span" , agent : "agents.Agent" ) -> None :
7149 span .set_data (
7250 SPANDATA .GEN_AI_SYSTEM , "openai"
0 commit comments