diff --git a/sentry_sdk/integrations/openai_agents/spans/ai_client.py b/sentry_sdk/integrations/openai_agents/spans/ai_client.py index 5c095b6b6c..225c873762 100644 --- a/sentry_sdk/integrations/openai_agents/spans/ai_client.py +++ b/sentry_sdk/integrations/openai_agents/spans/ai_client.py @@ -216,6 +216,8 @@ def ai_client_context( }, ) + context.span.set_attribute(SPANDATA.GEN_AI_PROVIDER_NAME, "openai") + _set_agent_data(context.span, agent) if client_options["data_collection"]["gen_ai"]["inputs"]: diff --git a/sentry_sdk/integrations/openai_agents/utils.py b/sentry_sdk/integrations/openai_agents/utils.py index 7d631aff27..84330cdf51 100644 --- a/sentry_sdk/integrations/openai_agents/utils.py +++ b/sentry_sdk/integrations/openai_agents/utils.py @@ -45,9 +45,6 @@ def _capture_exception(exc: "Any") -> None: def _set_agent_data(span: "Span", agent: "agents.Agent") -> None: - span.set_attribute( - SPANDATA.GEN_AI_PROVIDER_NAME, "openai" - ) # See footnote for https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-system for explanation why. span.set_attribute(SPANDATA.GEN_AI_AGENT_NAME, agent.name) diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index 4b3048dc3d..6bd507c511 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -481,7 +481,6 @@ async def test_agent_invocation_span_no_sensitive_data( assert "gen_ai.response.text" not in invoke_agent_span["attributes"] assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent" - assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent" assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100 assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4" @@ -762,7 +761,6 @@ async def test_agent_invocation_span( ) assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent" - assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent" assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100 assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4" @@ -885,7 +883,6 @@ def test_agent_invocation_span_sync_no_sensitive_data( assert invoke_agent_span["name"] == "invoke_agent test_agent" assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent" - assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent" assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100 assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4" @@ -1150,7 +1147,6 @@ def test_agent_invocation_span_sync( assert invoke_agent_span["name"] == "invoke_agent test_agent" assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent" - assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent" assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100 assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4" @@ -1306,7 +1302,6 @@ async def test_tool_execution_span( assert agent_span["attributes"]["gen_ai.request.model"] == "gpt-4" assert agent_span["attributes"]["gen_ai.request.temperature"] == 0.7 assert agent_span["attributes"]["gen_ai.request.top_p"] == 1.0 - assert agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert ai_client_span1["name"] == "chat gpt-4" assert ai_client_span1["attributes"]["gen_ai.operation.name"] == "chat" @@ -1373,7 +1368,6 @@ async def test_tool_execution_span( assert tool_span["attributes"]["gen_ai.request.model"] == "gpt-4" assert tool_span["attributes"]["gen_ai.request.temperature"] == 0.7 assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0 - assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool" assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}' assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool" @@ -1566,7 +1560,6 @@ async def test_run_streamed_tool_execution_span( assert agent_span["attributes"]["gen_ai.request.model"] == "gpt-4" assert agent_span["attributes"]["gen_ai.request.temperature"] == 0.7 assert agent_span["attributes"]["gen_ai.request.top_p"] == 1.0 - assert agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert tool_span["name"] == "execute_tool simple_test_tool" assert tool_span["attributes"]["gen_ai.agent.name"] == "test_agent" @@ -1576,7 +1569,6 @@ async def test_run_streamed_tool_execution_span( assert tool_span["attributes"]["gen_ai.request.model"] == "gpt-4" assert tool_span["attributes"]["gen_ai.request.temperature"] == 0.7 assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0 - assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool" assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}' assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"