Skip to content

Commit ffb339f

Browse files
merge
2 parents 5e8c254 + 43920b5 commit ffb339f

11 files changed

Lines changed: 304 additions & 299 deletions

File tree

sentry_sdk/client.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ def _serialized_v1_span_to_serialized_v2_span(
174174
res["span_id"] = span["span_id"]
175175

176176
if "description" in span:
177-
res["name"] = span["description"]
178-
elif (
179-
"op" in span
180-
): # fallback based on observed downstream fallback for transactions
181-
res["name"] = span["op"]
177+
description = span["description"]
178+
179+
if description is None and "op" in span:
180+
description = span["op"]
181+
182+
res["name"] = description
182183

183184
if "start_timestamp" in span:
184185
start_timestamp = None
@@ -1082,6 +1083,8 @@ def capture_event(
10821083
event_id = event.get("event_id")
10831084
if event_id is None:
10841085
event["event_id"] = event_id = uuid.uuid4().hex
1086+
1087+
span_recorder_has_gen_ai_span = event.pop("_has_gen_ai_span", False)
10851088
event_opt = self._prepare_event(event, hint, scope)
10861089
if event_opt is None:
10871090
return None
@@ -1120,8 +1123,6 @@ def capture_event(
11201123
if is_transaction and isinstance(profile, Profile):
11211124
envelope.add_profile(profile.to_json(event_opt, self.options))
11221125

1123-
span_recorder_has_gen_ai_span = event.pop("_has_gen_ai_span", False)
1124-
11251126
if is_transaction and not span_recorder_has_gen_ai_span:
11261127
envelope.add_transaction(event_opt)
11271128
elif is_transaction:
@@ -1135,7 +1136,7 @@ def capture_event(
11351136
envelope.add_transaction(event_opt)
11361137

11371138
converted_gen_ai_spans = [
1138-
_serialized_v1_span_to_serialized_v2_span(span, event)
1139+
_serialized_v1_span_to_serialized_v2_span(span, event_opt)
11391140
for span in gen_ai_spans
11401141
if isinstance(span, dict)
11411142
]
@@ -1148,7 +1149,10 @@ def capture_event(
11481149
"item_count": len(converted_gen_ai_spans),
11491150
},
11501151
payload=PayloadRef(
1151-
json={"items": converted_gen_ai_spans},
1152+
json={
1153+
"version": 2,
1154+
"items": converted_gen_ai_spans,
1155+
},
11521156
),
11531157
)
11541158
)

0 commit comments

Comments
 (0)