Skip to content

Commit f9855c9

Browse files
chore: Remove Scope._gen_ai_original_message_count (#7489)
This original message count is never set since truncation for GenAI spans was removed.
1 parent 4db9e7d commit f9855c9

2 files changed

Lines changed: 0 additions & 24 deletions

File tree

‎sentry_sdk/client.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from sentry_sdk.consts import (
1919
DEFAULT_MAX_VALUE_LENGTH,
2020
DEFAULT_OPTIONS,
21-
SPANDATA,
2221
SPANSTATUS,
2322
VERSION,
2423
ClientConstructor,
@@ -780,22 +779,6 @@ def _prepare_event(
780779
if event_scrubber:
781780
event_scrubber.scrub_event(event)
782781

783-
if scope is not None and scope._gen_ai_original_message_count:
784-
spans: "List[Dict[str, Any]] | AnnotatedValue" = event.get("spans", [])
785-
if isinstance(spans, list):
786-
for span in spans:
787-
span_id = span.get("span_id", None)
788-
span_data = span.get("data", {})
789-
if (
790-
span_id
791-
and span_id in scope._gen_ai_original_message_count
792-
and SPANDATA.GEN_AI_REQUEST_MESSAGES in span_data
793-
):
794-
span_data[SPANDATA.GEN_AI_REQUEST_MESSAGES] = AnnotatedValue(
795-
span_data[SPANDATA.GEN_AI_REQUEST_MESSAGES],
796-
{"len": scope._gen_ai_original_message_count[span_id]},
797-
)
798-
799782
if previous_total_breadcrumbs is not None:
800783
event["breadcrumbs"] = AnnotatedValue(
801784
event.get("breadcrumbs", {"values": []}),

‎sentry_sdk/scope.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ class Scope:
212212
"_extras",
213213
"_breadcrumbs",
214214
"_n_breadcrumbs_truncated",
215-
"_gen_ai_original_message_count",
216215
"_gen_ai_conversation_id",
217216
"_event_processors",
218217
"_error_processors",
@@ -243,7 +242,6 @@ def __init__(
243242
self._name: "Optional[str]" = None
244243
self._propagation_context: "Optional[PropagationContext]" = None
245244
self._n_breadcrumbs_truncated: int = 0
246-
self._gen_ai_original_message_count: "Dict[str, int]" = {}
247245

248246
self._server_segment_span: "Optional[StreamedSpan]" = None
249247

@@ -279,7 +277,6 @@ def __copy__(self) -> "Scope":
279277

280278
rv._breadcrumbs = copy(self._breadcrumbs)
281279
rv._n_breadcrumbs_truncated = self._n_breadcrumbs_truncated
282-
rv._gen_ai_original_message_count = self._gen_ai_original_message_count.copy()
283280
rv._event_processors = self._event_processors.copy()
284281
rv._error_processors = self._error_processors.copy()
285282
rv._propagation_context = self._propagation_context
@@ -1630,10 +1627,6 @@ def update_from_scope(self, scope: "Scope") -> None:
16301627
self._n_breadcrumbs_truncated = (
16311628
self._n_breadcrumbs_truncated + scope._n_breadcrumbs_truncated
16321629
)
1633-
if scope._gen_ai_original_message_count:
1634-
self._gen_ai_original_message_count.update(
1635-
scope._gen_ai_original_message_count
1636-
)
16371630
if scope._gen_ai_conversation_id:
16381631
self._gen_ai_conversation_id = scope._gen_ai_conversation_id
16391632
if scope._span:

0 commit comments

Comments
 (0)