File tree Expand file tree Collapse file tree
sentry_sdk/integrations/pydantic_ai/spans Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99)
1010from sentry_sdk .consts import OP , SPANDATA
1111from sentry_sdk .traces import StreamedSpan
12- from sentry_sdk .tracing_utils import has_span_streaming_enabled
12+ from sentry_sdk .tracing_utils import (
13+ has_span_streaming_enabled ,
14+ should_truncate_gen_ai_input ,
15+ )
1316from sentry_sdk .utils import safe_serialize
1417
1518from ..consts import SPAN_ORIGIN
@@ -200,9 +203,9 @@ def _set_input_messages(
200203 client = sentry_sdk .get_client ()
201204 scope = sentry_sdk .get_current_scope ()
202205 messages_data = (
203- normalized_messages
204- if client .options . get ( "stream_gen_ai_spans" , False )
205- else truncate_and_annotate_messages ( normalized_messages , span , scope )
206+ truncate_and_annotate_messages ( normalized_messages , span , scope )
207+ if should_truncate_gen_ai_input ( client .options )
208+ else normalized_messages
206209 )
207210 set_data_normalized (
208211 span , SPANDATA .GEN_AI_REQUEST_MESSAGES , messages_data , unpack = False
Original file line number Diff line number Diff line change 99)
1010from sentry_sdk .consts import OP , SPANDATA
1111from sentry_sdk .traces import StreamedSpan
12- from sentry_sdk .tracing_utils import has_span_streaming_enabled
12+ from sentry_sdk .tracing_utils import (
13+ has_span_streaming_enabled ,
14+ should_truncate_gen_ai_input ,
15+ )
1316
1417from ..consts import SPAN_ORIGIN
1518from ..utils import (
@@ -137,9 +140,9 @@ def invoke_agent_span(
137140 client = sentry_sdk .get_client ()
138141 scope = sentry_sdk .get_current_scope ()
139142 messages_data = (
140- normalized_messages
141- if client .options . get ( "stream_gen_ai_spans" , False )
142- else truncate_and_annotate_messages ( normalized_messages , span , scope )
143+ truncate_and_annotate_messages ( normalized_messages , span , scope )
144+ if should_truncate_gen_ai_input ( client .options )
145+ else normalized_messages
143146 )
144147 set_data_normalized (
145148 span , SPANDATA .GEN_AI_REQUEST_MESSAGES , messages_data , unpack = False
You can’t perform that action at this time.
0 commit comments