File tree Expand file tree Collapse file tree
sentry_sdk/integrations/boto3/_services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,6 +188,10 @@ def sentry_patched_iter(
188188 yield event
189189 continue
190190
191+ if "messageStop" in event :
192+ finish_reasons : "list[str]" = [event ["messageStop" ]["stopReason" ]]
193+ set_on_span (SPANDATA .GEN_AI_RESPONSE_FINISH_REASONS , finish_reasons )
194+
191195 if "messageStop" in event and role is not None :
192196 for block in content_blocks .values ():
193197 if "toolUse" not in block :
Original file line number Diff line number Diff line change @@ -990,6 +990,9 @@ def test_converse_stream(
990990 assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 1024
991991 assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_TEMPERATURE ] == 0.7
992992 assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_TOP_P ] == 0.9
993+ assert span ["attributes" ][SPANDATA .GEN_AI_RESPONSE_FINISH_REASONS ] == [
994+ "end_turn"
995+ ]
993996
994997 assert span ["attributes" ][SPANDATA .GEN_AI_USAGE_OUTPUT_TOKENS ] == 20
995998 assert span ["attributes" ][SPANDATA .GEN_AI_USAGE_TOTAL_TOKENS ] == 30
@@ -1029,6 +1032,7 @@ def test_converse_stream(
10291032 assert span ["data" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 1024
10301033 assert span ["data" ][SPANDATA .GEN_AI_REQUEST_TEMPERATURE ] == 0.7
10311034 assert span ["data" ][SPANDATA .GEN_AI_REQUEST_TOP_P ] == 0.9
1035+ assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_FINISH_REASONS ] == ["end_turn" ]
10321036
10331037 assert span ["data" ][SPANDATA .GEN_AI_USAGE_OUTPUT_TOKENS ] == 20
10341038 assert span ["data" ][SPANDATA .GEN_AI_USAGE_TOTAL_TOKENS ] == 30
You can’t perform that action at this time.
0 commit comments