@@ -81,14 +81,17 @@ def test_nonstreaming_chat_completion(
8181 tx = events [0 ]
8282 assert tx ["type" ] == "transaction"
8383 span = tx ["spans" ][0 ]
84- assert span ["op" ] == "ai.chat_completions.create.openai "
84+ assert span ["op" ] == "gen_ai.chat "
8585
8686 if send_default_pii and include_prompts :
87- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
88- assert "the model response" in span ["data" ][SPANDATA .AI_RESPONSES ]["content" ]
87+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
88+ assert (
89+ "the model response"
90+ in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]["content" ]
91+ )
8992 else :
90- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
91- assert SPANDATA .AI_RESPONSES not in span ["data" ]
93+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
94+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
9295
9396 assert span ["data" ]["gen_ai.usage.output_tokens" ] == 10
9497 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
@@ -123,14 +126,17 @@ async def test_nonstreaming_chat_completion_async(
123126 tx = events [0 ]
124127 assert tx ["type" ] == "transaction"
125128 span = tx ["spans" ][0 ]
126- assert span ["op" ] == "ai.chat_completions.create.openai "
129+ assert span ["op" ] == "gen_ai.chat "
127130
128131 if send_default_pii and include_prompts :
129- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
130- assert "the model response" in span ["data" ][SPANDATA .AI_RESPONSES ]["content" ]
132+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
133+ assert (
134+ "the model response"
135+ in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]["content" ]
136+ )
131137 else :
132- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
133- assert SPANDATA .AI_RESPONSES not in span ["data" ]
138+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
139+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
134140
135141 assert span ["data" ]["gen_ai.usage.output_tokens" ] == 10
136142 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
@@ -216,14 +222,14 @@ def test_streaming_chat_completion(
216222 tx = events [0 ]
217223 assert tx ["type" ] == "transaction"
218224 span = tx ["spans" ][0 ]
219- assert span ["op" ] == "ai.chat_completions.create.openai "
225+ assert span ["op" ] == "gen_ai.chat "
220226
221227 if send_default_pii and include_prompts :
222- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
223- assert "hello world" in span ["data" ][SPANDATA .AI_RESPONSES ]
228+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
229+ assert "hello world" in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]
224230 else :
225- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
226- assert SPANDATA .AI_RESPONSES not in span ["data" ]
231+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
232+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
227233
228234 try :
229235 import tiktoken # type: ignore # noqa # pylint: disable=unused-import
@@ -312,14 +318,14 @@ async def test_streaming_chat_completion_async(
312318 tx = events [0 ]
313319 assert tx ["type" ] == "transaction"
314320 span = tx ["spans" ][0 ]
315- assert span ["op" ] == "ai.chat_completions.create.openai "
321+ assert span ["op" ] == "gen_ai.chat "
316322
317323 if send_default_pii and include_prompts :
318- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]["content" ]
319- assert "hello world" in span ["data" ][SPANDATA .AI_RESPONSES ]
324+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]["content" ]
325+ assert "hello world" in span ["data" ][SPANDATA .GEN_AI_RESPONSE_TEXT ]
320326 else :
321- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
322- assert SPANDATA .AI_RESPONSES not in span ["data" ]
327+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
328+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span ["data" ]
323329
324330 try :
325331 import tiktoken # type: ignore # noqa # pylint: disable=unused-import
@@ -403,11 +409,11 @@ def test_embeddings_create(
403409 tx = events [0 ]
404410 assert tx ["type" ] == "transaction"
405411 span = tx ["spans" ][0 ]
406- assert span ["op" ] == "ai .embeddings.create.openai "
412+ assert span ["op" ] == "gen_ai .embeddings"
407413 if send_default_pii and include_prompts :
408- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]
414+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]
409415 else :
410- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
416+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
411417
412418 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
413419 assert span ["data" ]["gen_ai.usage.total_tokens" ] == 30
@@ -451,11 +457,11 @@ async def test_embeddings_create_async(
451457 tx = events [0 ]
452458 assert tx ["type" ] == "transaction"
453459 span = tx ["spans" ][0 ]
454- assert span ["op" ] == "ai .embeddings.create.openai "
460+ assert span ["op" ] == "gen_ai .embeddings"
455461 if send_default_pii and include_prompts :
456- assert "hello" in span ["data" ][SPANDATA .AI_INPUT_MESSAGES ]
462+ assert "hello" in span ["data" ][SPANDATA .GEN_AI_REQUEST_MESSAGES ]
457463 else :
458- assert SPANDATA .AI_INPUT_MESSAGES not in span ["data" ]
464+ assert SPANDATA .GEN_AI_REQUEST_MESSAGES not in span ["data" ]
459465
460466 assert span ["data" ]["gen_ai.usage.input_tokens" ] == 20
461467 assert span ["data" ]["gen_ai.usage.total_tokens" ] == 30
0 commit comments