@@ -1194,10 +1194,9 @@ def test_text_generation_data_collection(
11941194
11951195 captured = capture_items ("span" )
11961196
1197- with sentry_sdk .start_transaction (name = "test" ):
1198- client .text_generation ("Hello" , stream = False , details = True )
1197+ client .text_generation ("Hello" , stream = False , details = True )
11991198 sentry_sdk .flush ()
1200- spans = [item .payload for item in captured if item . type == "span" ]
1199+ spans = [item .payload for item in captured ]
12011200 (span ,) = [sp for sp in spans if sp ["attributes" ]["sentry.op" ].startswith ("gen_ai" )]
12021201 span_data = span ["attributes" ]
12031202
@@ -1330,11 +1329,10 @@ def test_text_generation_streaming_data_collection(
13301329
13311330 captured = capture_items ("span" )
13321331
1333- with sentry_sdk .start_transaction (name = "test" ):
1334- for _ in client .text_generation (prompt = "Hello" , stream = True , details = True ):
1335- pass
1332+ for _ in client .text_generation (prompt = "Hello" , stream = True , details = True ):
1333+ pass
13361334 sentry_sdk .flush ()
1337- spans = [item .payload for item in captured if item . type == "span" ]
1335+ spans = [item .payload for item in captured ]
13381336 (span ,) = [sp for sp in spans if sp ["attributes" ]["sentry.op" ].startswith ("gen_ai" )]
13391337 span_data = span ["attributes" ]
13401338
@@ -1476,14 +1474,13 @@ def test_chat_completion_data_collection_tools(
14761474
14771475 captured = capture_items ("span" )
14781476
1479- with sentry_sdk .start_transaction (name = "test" ):
1480- client .chat_completion (
1481- messages = [{"role" : "user" , "content" : "What is the weather in Paris?" }],
1482- tools = DATA_COLLECTION_TOOLS ,
1483- tool_choice = "auto" ,
1484- )
1477+ client .chat_completion (
1478+ messages = [{"role" : "user" , "content" : "What is the weather in Paris?" }],
1479+ tools = DATA_COLLECTION_TOOLS ,
1480+ tool_choice = "auto" ,
1481+ )
14851482 sentry_sdk .flush ()
1486- spans = [item .payload for item in captured if item . type == "span" ]
1483+ spans = [item .payload for item in captured ]
14871484 (span ,) = [sp for sp in spans if sp ["attributes" ]["sentry.op" ].startswith ("gen_ai" )]
14881485 span_data = span ["attributes" ]
14891486
@@ -1638,16 +1635,15 @@ def test_chat_completion_streaming_data_collection_tools(
16381635
16391636 captured = capture_items ("span" )
16401637
1641- with sentry_sdk .start_transaction (name = "test" ):
1642- for _ in client .chat_completion (
1643- messages = [{"role" : "user" , "content" : "What is the weather in Paris?" }],
1644- tools = DATA_COLLECTION_TOOLS ,
1645- tool_choice = "auto" ,
1646- stream = True ,
1647- ):
1648- pass
1638+ for _ in client .chat_completion (
1639+ messages = [{"role" : "user" , "content" : "What is the weather in Paris?" }],
1640+ tools = DATA_COLLECTION_TOOLS ,
1641+ tool_choice = "auto" ,
1642+ stream = True ,
1643+ ):
1644+ pass
16491645 sentry_sdk .flush ()
1650- spans = [item .payload for item in captured if item . type == "span" ]
1646+ spans = [item .payload for item in captured ]
16511647 (span ,) = [sp for sp in spans if sp ["attributes" ]["sentry.op" ].startswith ("gen_ai" )]
16521648 span_data = span ["attributes" ]
16531649
0 commit comments