Skip to content

Commit e9a4d8a

Browse files
chore(openai-agents): Only set gen_ai.provider.name on AI Client spans
1 parent b2d5572 commit e9a4d8a

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
@@ -217,6 +217,8 @@ def ai_client_context(
217217
},
218218
)
219219

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

222224
if has_data_collection_enabled(client_options):

‎sentry_sdk/integrations/openai_agents/utils.py‎

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

4848

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

5451
span.set_attribute(SPANDATA.GEN_AI_AGENT_NAME, agent.name)
5552

‎tests/integrations/openai_agents/test_openai_agents.py‎

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

474474
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
475-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
476475
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
477476
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
478477
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -1212,7 +1211,6 @@ async def test_agent_invocation_span(
12121211
)
12131212

12141213
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
1215-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
12161214
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
12171215
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
12181216
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -1329,7 +1327,6 @@ def test_agent_invocation_span_sync_no_pii(
13291327

13301328
assert invoke_agent_span["name"] == "invoke_agent test_agent"
13311329
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
1332-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
13331330
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
13341331
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
13351332
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -1589,7 +1586,6 @@ def test_agent_invocation_span_sync(
15891586

15901587
assert invoke_agent_span["name"] == "invoke_agent test_agent"
15911588
assert invoke_agent_span["attributes"]["gen_ai.operation.name"] == "invoke_agent"
1592-
assert invoke_agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
15931589
assert invoke_agent_span["attributes"]["gen_ai.agent.name"] == "test_agent"
15941590
assert invoke_agent_span["attributes"]["gen_ai.request.max_tokens"] == 100
15951591
assert invoke_agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
@@ -1740,7 +1736,6 @@ async def test_tool_execution_span(
17401736
assert agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
17411737
assert agent_span["attributes"]["gen_ai.request.temperature"] == 0.7
17421738
assert agent_span["attributes"]["gen_ai.request.top_p"] == 1.0
1743-
assert agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
17441739

17451740
assert ai_client_span1["name"] == "chat gpt-4"
17461741
assert ai_client_span1["attributes"]["gen_ai.operation.name"] == "chat"
@@ -1807,7 +1802,6 @@ async def test_tool_execution_span(
18071802
assert tool_span["attributes"]["gen_ai.request.model"] == "gpt-4"
18081803
assert tool_span["attributes"]["gen_ai.request.temperature"] == 0.7
18091804
assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0
1810-
assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
18111805
assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool"
18121806
assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}'
18131807
assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"
@@ -1995,7 +1989,6 @@ async def test_run_streamed_tool_execution_span(
19951989
assert agent_span["attributes"]["gen_ai.request.model"] == "gpt-4"
19961990
assert agent_span["attributes"]["gen_ai.request.temperature"] == 0.7
19971991
assert agent_span["attributes"]["gen_ai.request.top_p"] == 1.0
1998-
assert agent_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
19991992

20001993
assert tool_span["name"] == "execute_tool simple_test_tool"
20011994
assert tool_span["attributes"]["gen_ai.agent.name"] == "test_agent"
@@ -2005,7 +1998,6 @@ async def test_run_streamed_tool_execution_span(
20051998
assert tool_span["attributes"]["gen_ai.request.model"] == "gpt-4"
20061999
assert tool_span["attributes"]["gen_ai.request.temperature"] == 0.7
20072000
assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0
2008-
assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
20092001
assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool"
20102002
assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}'
20112003
assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"

0 commit comments

Comments
 (0)