@@ -195,9 +195,10 @@ def test_basic_chat_chain(mock_client, stream):
195195 assert generation_props ["$ai_output_tokens" ] == 10
196196 assert generation_props ["$ai_http_status" ] == 200
197197 assert isinstance (generation_props ["$ai_latency" ], float )
198- assert "$ai_generation_id " in generation_props
198+ assert "$ai_span_id " in generation_props
199199 assert generation_props ["$ai_parent_id" ] == trace_props ["$ai_trace_id" ]
200200 assert generation_props ["$ai_trace_id" ] == trace_props ["$ai_trace_id" ]
201+ assert generation_props ["$ai_span_name" ] == "FakeMessagesListChatModel"
201202
202203 # Trace is last
203204 assert trace_args ["event" ] == "$ai_trace"
@@ -266,7 +267,7 @@ async def test_async_basic_chat_chain(mock_client, stream):
266267 assert generation_props ["$ai_output_tokens" ] == 10
267268 assert generation_props ["$ai_http_status" ] == 200
268269 assert isinstance (generation_props ["$ai_latency" ], float )
269- assert "$ai_generation_id " in generation_props
270+ assert "$ai_span_id " in generation_props
270271 assert generation_props ["$ai_parent_id" ] == trace_props ["$ai_trace_id" ]
271272 assert generation_props ["$ai_trace_id" ] == trace_props ["$ai_trace_id" ]
272273
@@ -398,7 +399,7 @@ def test_trace_id_and_inputs_for_multiple_chains(mock_client):
398399 assert first_generation_props ["$ai_output_choices" ] == [{"role" : "assistant" , "content" : "Bar" }]
399400 assert first_generation_props ["$ai_http_status" ] == 200
400401 assert isinstance (first_generation_props ["$ai_latency" ], float )
401- assert "$ai_generation_id " in first_generation_props
402+ assert "$ai_span_id " in first_generation_props
402403 assert first_generation_props ["$ai_parent_id" ] == trace_props ["$ai_trace_id" ]
403404 assert first_generation_props ["$ai_trace_id" ] == trace_props ["$ai_trace_id" ]
404405
@@ -428,7 +429,7 @@ def test_trace_id_and_inputs_for_multiple_chains(mock_client):
428429 assert isinstance (trace_props ["$ai_output_state" ], AIMessage )
429430 assert trace_props ["$ai_output_state" ].content == "Bar"
430431 assert trace_props ["$ai_trace_id" ] is not None
431- assert trace_props ["$ai_trace_name " ] == "RunnableSequence"
432+ assert trace_props ["$ai_span_name " ] == "RunnableSequence"
432433
433434
434435def test_personless_mode (mock_client ):
@@ -559,7 +560,7 @@ def test_metadata(mock_client):
559560 assert trace_call_args ["distinct_id" ] == "test_id"
560561 assert trace_call_args ["event" ] == "$ai_trace"
561562 assert trace_call_props ["$ai_trace_id" ] == "test-trace-id"
562- assert trace_call_props ["$ai_trace_name " ] == "RunnableSequence"
563+ assert trace_call_props ["$ai_span_name " ] == "RunnableSequence"
563564 assert trace_call_props ["foo" ] == "bar"
564565 assert trace_call_props ["$ai_input_state" ] == {"plan" : None }
565566 assert isinstance (trace_call_props ["$ai_output_state" ], AIMessage )
@@ -678,8 +679,8 @@ def test_graph_state(mock_client):
678679 # 7. Generation, fake_llm
679680 assert calls [6 ]["event" ] == "$ai_generation"
680681 assert calls [6 ]["properties" ]["$ai_parent_id" ] == calls [7 ]["properties" ]["$ai_span_id" ]
681- assert "$ai_generation_id " in calls [6 ]["properties" ]
682- assert "$ai_span_name" not in calls [6 ]["properties" ]
682+ assert "$ai_span_id " in calls [6 ]["properties" ]
683+ assert calls [6 ]["properties" ][ "$ai_span_name" ] == "FakeMessagesListChatModel"
683684
684685 # 8. Span, RunnableSequence
685686 assert calls [7 ]["event" ] == "$ai_span"
@@ -700,7 +701,7 @@ def test_graph_state(mock_client):
700701
701702 # 11. Trace
702703 assert trace_args ["event" ] == "$ai_trace"
703- assert trace_props ["$ai_trace_name " ] == "LangGraph"
704+ assert trace_props ["$ai_span_name " ] == "LangGraph"
704705
705706 assert len (trace_props ["$ai_input_state" ]["messages" ]) == 1
706707 assert isinstance (trace_props ["$ai_input_state" ]["messages" ][0 ], HumanMessage )
@@ -760,7 +761,7 @@ def runnable(_):
760761 assert mock_client .capture .call_count == 1
761762 trace_call_args = mock_client .capture .call_args_list [0 ][1 ]
762763 assert trace_call_args ["event" ] == "$ai_trace"
763- assert trace_call_args ["properties" ]["$ai_trace_name " ] == "runnable"
764+ assert trace_call_args ["properties" ]["$ai_span_name " ] == "runnable"
764765
765766
766767def test_openai_error (mock_client ):
@@ -1230,9 +1231,9 @@ async def sleep(x): # -> Any:
12301231 assert first_call [1 ]["event" ] == "$ai_span"
12311232 assert second_call [1 ]["event" ] == "$ai_generation"
12321233 assert third_call [1 ]["event" ] == "$ai_trace"
1233- assert third_call [1 ]["properties" ]["$ai_trace_name " ] == "RunnableSequence"
1234+ assert third_call [1 ]["properties" ]["$ai_span_name " ] == "RunnableSequence"
12341235 assert fourth_call [1 ]["event" ] == "$ai_trace"
1235- assert fourth_call [1 ]["properties" ]["$ai_trace_name " ] == "sleep"
1236+ assert fourth_call [1 ]["properties" ]["$ai_span_name " ] == "sleep"
12361237 assert (
12371238 min (approximate_latency - 1 , 0 ) <= math .floor (third_call [1 ]["properties" ]["$ai_latency" ]) <= approximate_latency
12381239 )
0 commit comments