diff --git a/instrumentation/opentelemetry-instrumentation-genai-openai-agents/.changelog/710.fixed b/instrumentation/opentelemetry-instrumentation-genai-openai-agents/.changelog/710.fixed new file mode 100644 index 000000000..ff4abb1e9 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-genai-openai-agents/.changelog/710.fixed @@ -0,0 +1 @@ +Do not record `gen_ai.provider.name` on tool execution metric attributes. diff --git a/instrumentation/opentelemetry-instrumentation-genai-openai-agents/src/opentelemetry/instrumentation/genai/openai_agents/processor.py b/instrumentation/opentelemetry-instrumentation-genai-openai-agents/src/opentelemetry/instrumentation/genai/openai_agents/processor.py index 31e630882..7cac2b253 100644 --- a/instrumentation/opentelemetry-instrumentation-genai-openai-agents/src/opentelemetry/instrumentation/genai/openai_agents/processor.py +++ b/instrumentation/opentelemetry-instrumentation-genai-openai-agents/src/opentelemetry/instrumentation/genai/openai_agents/processor.py @@ -43,9 +43,6 @@ FunctionSpanData, ) -from opentelemetry.semconv._incubating.attributes import ( - gen_ai_attributes as GenAI, -) from opentelemetry.semconv._incubating.attributes.error_attributes import ( ErrorTypeValues, ) @@ -117,13 +114,6 @@ def on_span_start(self, span: Span[Any]) -> None: name=span_data.name, tool_type="function", ) - - # ToolInvocation does not include provider in metric attributes - # by default; set it so gen_ai.client.operation.duration carries - # the required gen_ai.provider.name attribute. - invocation.metric_attributes[GenAI.GEN_AI_PROVIDER_NAME] = ( - self._provider - ) self._invocations[span] = invocation return # Other span_data types (GenerationSpanData, ResponseSpanData, diff --git a/instrumentation/opentelemetry-instrumentation-genai-openai-agents/tests/test_processor.py b/instrumentation/opentelemetry-instrumentation-genai-openai-agents/tests/test_processor.py index 903a0856d..82c914687 100644 --- a/instrumentation/opentelemetry-instrumentation-genai-openai-agents/tests/test_processor.py +++ b/instrumentation/opentelemetry-instrumentation-genai-openai-agents/tests/test_processor.py @@ -84,9 +84,7 @@ def test_agent_span_creates_invoke_local_agent() -> None: handler.invoke_local_agent.return_value.stop.assert_called_once_with() -def test_function_span_creates_tool_invocation_and_sets_provider_metric() -> ( - None -): +def test_function_span_creates_tool_invocation() -> None: handler = _build_handler() handler.tool.return_value = MagicMock( spec=ToolInvocation, @@ -108,10 +106,7 @@ def test_function_span_creates_tool_invocation_and_sets_provider_metric() -> ( tool_type="function", ) tool_invocation = handler.tool.return_value - - assert ( - tool_invocation.metric_attributes["gen_ai.provider.name"] == "openai" - ) + assert "gen_ai.provider.name" not in tool_invocation.metric_attributes # Input and output both get populated on the agents library span_data # while the tool runs, i.e. after on_span_start; our on_span_end reads