@@ -137,14 +137,17 @@ def test_nonstreaming_chat_completion(
137137 tx = events [0 ]
138138 assert tx ["type" ] == "transaction"
139139 span = tx ["spans" ][0 ]
140- assert span ["op" ] == "ai.chat_completions.create.openai "
140+ assert span ["op" ] == "gen_ai.chat "
141141
142142 if send_default_pii and include_prompts :
143- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
144- assert "the model response" in span ["data" ][SPANDATA .AI_RESPONSES ]["content" ]
143+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
144+ assert (
145+ "the model response"
146+ in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]["content" ]
147+ )
145148 else :
146- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
147- assert SPANDATA .AI_RESPONSES not in span ["data" ]
149+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
150+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
148151
149152 assert span ["data" ]["gen_ai.usage.output_tokens" ] == 10
150153 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
@@ -179,14 +182,17 @@ async def test_nonstreaming_chat_completion_async(
179182 tx = events [0 ]
180183 assert tx ["type" ] == "transaction"
181184 span = tx ["spans" ][0 ]
182- assert span ["op" ] == "ai.chat_completions.create.openai "
185+ assert span ["op" ] == "gen_ai.chat "
183186
184187 if send_default_pii and include_prompts :
185- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
186- assert "the model response" in span ["data" ][SPANDATA .AI_RESPONSES ]["content" ]
188+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
189+ assert (
190+ "the model response"
191+ in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]["content" ]
192+ )
187193 else :
188- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
189- assert SPANDATA .AI_RESPONSES not in span ["data" ]
194+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
195+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
190196
191197 assert span ["data" ]["gen_ai.usage.output_tokens" ] == 10
192198 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
@@ -272,14 +278,14 @@ def test_streaming_chat_completion(
272278 tx = events [0 ]
273279 assert tx ["type" ] == "transaction"
274280 span = tx ["spans" ][0 ]
275- assert span ["op" ] == "ai.chat_completions.create.openai "
281+ assert span ["op" ] == "gen_ai.chat "
276282
277283 if send_default_pii and include_prompts :
278- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
279- assert "hello world" in span ["data" ][SPANDATA .AI_RESPONSES ]
284+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
285+ assert "hello world" in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]
280286 else :
281- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
282- assert SPANDATA .AI_RESPONSES not in span ["data" ]
287+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
288+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
283289
284290 try :
285291 import tiktoken # type: ignore # noqa # pylint: disable=unused-import
@@ -368,14 +374,14 @@ async def test_streaming_chat_completion_async(
368374 tx = events [0 ]
369375 assert tx ["type" ] == "transaction"
370376 span = tx ["spans" ][0 ]
371- assert span ["op" ] == "ai.chat_completions.create.openai "
377+ assert span ["op" ] == "gen_ai.chat "
372378
373379 if send_default_pii and include_prompts :
374- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
375- assert "hello world" in span ["data" ][SPANDATA .AI_RESPONSES ]
380+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
381+ assert "hello world" in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]
376382 else :
377- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
378- assert SPANDATA .AI_RESPONSES not in span ["data" ]
383+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
384+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
379385
380386 try :
381387 import tiktoken # type: ignore # noqa # pylint: disable=unused-import
@@ -459,11 +465,11 @@ def test_embeddings_create(
459465 tx = events [0 ]
460466 assert tx ["type" ] == "transaction"
461467 span = tx ["spans" ][0 ]
462- assert span ["op" ] == "ai .embeddings.create.openai "
468+ assert span ["op" ] == "gen_ai .embeddings"
463469 if send_default_pii and include_prompts :
464- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]
470+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]
465471 else :
466- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
472+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
467473
468474 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
469475 assert span ["data" ]["gen_ai.usage.total_tokens" ] == 30
@@ -507,11 +513,11 @@ async def test_embeddings_create_async(
507513 tx = events [0 ]
508514 assert tx ["type" ] == "transaction"
509515 span = tx ["spans" ][0 ]
510- assert span ["op" ] == "ai .embeddings.create.openai "
516+ assert span ["op" ] == "gen_ai .embeddings"
511517 if send_default_pii and include_prompts :
512- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]
518+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]
513519 else :
514- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
520+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
515521
516522 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
517523 assert span ["data" ]["gen_ai.usage.total_tokens" ] == 30
0 commit comments