Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sentry_sdk/integrations/openai_agents/spans/ai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def ai_client_context(
},
)

context.span.set_attribute(SPANDATA.GEN_AI_PROVIDER_NAME, "openai")

_set_agent_data(context.span, agent)

if has_data_collection_enabled(client_options):
Expand Down
3 changes: 0 additions & 3 deletions sentry_sdk/integrations/openai_agents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,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)

Expand Down
8 changes: 0 additions & 8 deletions tests/integrations/openai_agents/test_openai_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ async def test_agent_invocation_span_no_pii(
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"
Expand Down Expand Up @@ -1212,7 +1211,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"
Expand Down Expand Up @@ -1329,7 +1327,6 @@ def test_agent_invocation_span_sync_no_pii(

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"
Expand Down Expand Up @@ -1589,7 +1586,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"
Expand Down Expand Up @@ -1740,7 +1736,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"
Expand Down Expand Up @@ -1807,7 +1802,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"
Expand Down Expand Up @@ -1995,7 +1989,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"
Expand All @@ -2005,7 +1998,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"
Expand Down
Loading