File tree Expand file tree Collapse file tree
util/opentelemetry-util-genai
src/opentelemetry/util/genai Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,7 +62,9 @@ def record(
6262 )
6363 else :
6464 # ToolCall
65- attributes [GenAI .GEN_AI_OPERATION_NAME ] = "execute_tool"
65+ attributes [GenAI .GEN_AI_OPERATION_NAME ] = (
66+ GenAI .GenAiOperationNameValues .EXECUTE_TOOL .value
67+ )
6668
6769 # Common attributes across invocation types
6870 if invocation .provider :
@@ -95,7 +97,7 @@ def record(
9597 context = span_context ,
9698 )
9799
98- # Token metrics only for LLMInvocation
100+ # Token metrics for LLMInvocations.
99101 if isinstance (invocation , LLMInvocation ):
100102 token_counts : list [tuple [int , str ]] = []
101103 if invocation .input_tokens is not None :
Original file line number Diff line number Diff line change @@ -393,7 +393,10 @@ def _apply_tool_call_attributes(
393393 - error.type (if operation ended in error)
394394 """
395395 # Set REQUIRED attribute
396- span .set_attribute (GenAI .GEN_AI_OPERATION_NAME , "execute_tool" )
396+ span .set_attribute (
397+ GenAI .GEN_AI_OPERATION_NAME ,
398+ GenAI .GenAiOperationNameValues .EXECUTE_TOOL .value ,
399+ )
397400
398401 # Set RECOMMENDED attributes (if present)
399402 if tool_call .name :
@@ -451,12 +454,6 @@ def _finish_tool_call_span(
451454 # Apply all attributes including result if available
452455 _apply_tool_call_attributes (span , tool_call , capture_content )
453456
454- # Set status based on error presence
455- if tool_call .error_type :
456- span .set_status (Status (StatusCode .ERROR ))
457- else :
458- span .set_status (Status (StatusCode .OK ))
459-
460457
461458__all__ = [
462459 "_apply_llm_finish_attributes" ,
Original file line number Diff line number Diff line change @@ -271,9 +271,6 @@ def test_stop_tool_call_ends_span(self):
271271 "Get current weather" ,
272272 )
273273
274- # Check status is OK
275- self .assertEqual (span .status .status_code , StatusCode .OK )
276-
277274 def test_stop_tool_call_without_start (self ):
278275 """Test stop without prior start is a no-op for ToolCall"""
279276 tool = ToolCall (name = "test" , arguments = {}, id = None )
@@ -355,7 +352,6 @@ def test_tool_call_context_manager_success(self):
355352
356353 span = spans [0 ]
357354 self .assertEqual (span .name , "execute_tool calculate_sum" )
358- self .assertEqual (span .status .status_code , StatusCode .OK )
359355 self .assertEqual (
360356 span .attributes [GenAI .GEN_AI_TOOL_NAME ], "calculate_sum"
361357 )
You can’t perform that action at this time.
0 commit comments