Skip to content

Commit b565fbd

Browse files
chore(openai-agents): Only set gen_ai.provider.name on AI Client spans (#7691)
The attribute was removed from OTel conventions in open-telemetry/semantic-conventions-genai@126e72f.
1 parent 8c2d49e commit b565fbd

3 files changed

Lines changed: 2 additions & 11 deletions

File tree

‎sentry_sdk/integrations/openai_agents/spans/ai_client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ def ai_client_context(
216216
},
217217
)
218218

219+
context.span.set_attribute(SPANDATA.GEN_AI_PROVIDER_NAME, "openai")
220+
219221
_set_agent_data(context.span, agent)
220222

221223
if client_options["data_collection"]["gen_ai"]["inputs"]:

‎sentry_sdk/integrations/openai_agents/utils.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ def _capture_exception(exc: "Any") -> None:
4545

4646

4747
def _set_agent_data(span: "Span", agent: "agents.Agent") -> None:
48-
span.set_attribute(
49-
SPANDATA.GEN_AI_PROVIDER_NAME, "openai"
50-
) # See footnote for https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-system for explanation why.
5148

5249
span.set_attribute(SPANDATA.GEN_AI_AGENT_NAME, agent.name)
5350

‎tests/integrations/openai_agents/test_openai_agents.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ async def test_agent_invocation_span_no_sensitive_data(
481481
assert "gen_ai.response.text" not in invoke_agent_span["attributes"]
482482

483483
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
484-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
485484
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
486485
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
487486
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -762,7 +761,6 @@ async def test_agent_invocation_span(
762761
)
763762

764763
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
765-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
766764
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
767765
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
768766
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -885,7 +883,6 @@ def test_agent_invocation_span_sync_no_sensitive_data(
885883

886884
assert invoke_agent_span["name"] == "invoke_agent test_agent"
887885
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
888-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
889886
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
890887
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
891888
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -1150,7 +1147,6 @@ def test_agent_invocation_span_sync(
11501147

11511148
assert invoke_agent_span["name"] == "invoke_agent test_agent"
11521149
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
1153-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
11541150
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
11551151
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
11561152
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -1306,7 +1302,6 @@ async def test_tool_execution_span(
13061302
assert agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
13071303
assert agent_span["attributes"]["gen_ai.request.temperature"] == 0.7
13081304
assert agent_span["attributes"]["gen_ai.request.top_p"] == 1.0
1309-
assert agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
13101305

13111306
assert ai_client_span1["name"] == "chat gpt-4"
13121307
assert ai_client_span1["attributes"]["gen_ai.operation.name"] == "chat"
@@ -1373,7 +1368,6 @@ async def test_tool_execution_span(
13731368
assert tool_span["attributes"]["gen_ai.request.model"] == "gpt-4"
13741369
assert tool_span["attributes"]["gen_ai.request.temperature"] == 0.7
13751370
assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0
1376-
assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
13771371
assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool"
13781372
assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}'
13791373
assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"
@@ -1566,7 +1560,6 @@ async def test_run_streamed_tool_execution_span(
15661560
assert agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
15671561
assert agent_span["attributes"]["gen_ai.request.temperature"] == 0.7
15681562
assert agent_span["attributes"]["gen_ai.request.top_p"] == 1.0
1569-
assert agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
15701563

15711564
assert tool_span["name"] == "execute_tool simple_test_tool"
15721565
assert tool_span["attributes"]["gen_ai.agent.name"] == "test_agent"
@@ -1576,7 +1569,6 @@ async def test_run_streamed_tool_execution_span(
15761569
assert tool_span["attributes"]["gen_ai.request.model"] == "gpt-4"
15771570
assert tool_span["attributes"]["gen_ai.request.temperature"] == 0.7
15781571
assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0
1579-
assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
15801572
assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool"
15811573
assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}'
15821574
assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"

0 commit comments

Comments
 (0)