@@ -1037,11 +1037,12 @@ def telemetry_test_tool(expression: str) -> str:
10371037 call_args = mock_histogram .record .call_args
10381038 assert call_args [0 ][0 ] > 0 # duration should be positive
10391039 attributes = call_args [1 ]["attributes" ]
1040- assert attributes [OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME ] == "telemetry_test_tool"
1041- assert attributes [OtelAttr .TOOL_CALL_ID ] == "test_call_id"
1042- assert OtelAttr .TOOL_ARGUMENTS not in attributes
1043- assert OtelAttr .TOOL_RESULT not in attributes
1044- assert expression not in attributes .values ()
1040+ assert attributes == {
1041+ OtelAttr .OPERATION : OtelAttr .TOOL_EXECUTION_OPERATION ,
1042+ OtelAttr .TOOL_NAME : "telemetry_test_tool" ,
1043+ OtelAttr .TOOL_TYPE : "function" ,
1044+ OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME : "telemetry_test_tool" ,
1045+ }
10451046
10461047
10471048@pytest .mark .parametrize ("enable_sensitive_data" , [False ], indirect = True )
@@ -1085,8 +1086,12 @@ def telemetry_test_tool(x: int, y: int) -> int:
10851086 call_args = mock_histogram .record .call_args
10861087 assert call_args [0 ][0 ] > 0 # duration should be positive
10871088 attributes = call_args [1 ]["attributes" ]
1088- assert attributes [OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME ] == "telemetry_test_tool"
1089- assert attributes [OtelAttr .TOOL_CALL_ID ] == "test_call_id"
1089+ assert attributes == {
1090+ OtelAttr .OPERATION : OtelAttr .TOOL_EXECUTION_OPERATION ,
1091+ OtelAttr .TOOL_NAME : "telemetry_test_tool" ,
1092+ OtelAttr .TOOL_TYPE : "function" ,
1093+ OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME : "telemetry_test_tool" ,
1094+ }
10901095
10911096
10921097@pytest .mark .parametrize ("enable_sensitive_data" , [True ], indirect = True )
@@ -1228,9 +1233,13 @@ def exception_test_tool(x: int, y: int) -> int:
12281233 mock_histogram .record .assert_called_once ()
12291234 call_args = mock_histogram .record .call_args
12301235 attributes = call_args [1 ]["attributes" ]
1231- assert attributes [OtelAttr .ERROR_TYPE ] == ValueError .__name__
1232- assert OtelAttr .TOOL_ARGUMENTS not in attributes
1233- assert OtelAttr .TOOL_RESULT not in attributes
1236+ assert attributes == {
1237+ OtelAttr .OPERATION : OtelAttr .TOOL_EXECUTION_OPERATION ,
1238+ OtelAttr .TOOL_NAME : "exception_test_tool" ,
1239+ OtelAttr .TOOL_TYPE : "function" ,
1240+ OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME : "exception_test_tool" ,
1241+ OtelAttr .ERROR_TYPE : ValueError .__name__ ,
1242+ }
12341243
12351244
12361245async def test_tool_invoke_telemetry_async_function (span_exporter : InMemorySpanExporter ):
@@ -1268,7 +1277,12 @@ async def async_telemetry_test(x: int, y: int) -> int:
12681277 mock_histogram .record .assert_called_once ()
12691278 call_args = mock_histogram .record .call_args
12701279 attributes = call_args [1 ]["attributes" ]
1271- assert attributes [OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME ] == "async_telemetry_test"
1280+ assert attributes == {
1281+ OtelAttr .OPERATION : OtelAttr .TOOL_EXECUTION_OPERATION ,
1282+ OtelAttr .TOOL_NAME : "async_telemetry_test" ,
1283+ OtelAttr .TOOL_TYPE : "function" ,
1284+ OtelAttr .MEASUREMENT_FUNCTION_TAG_NAME : "async_telemetry_test" ,
1285+ }
12721286
12731287
12741288async def test_tool_invoke_invalid_pydantic_args ():
0 commit comments