Skip to content

Commit 82e8a02

Browse files
committed
better span origin
1 parent 68cdbc4 commit 82e8a02

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

sentry_sdk/integrations/openai_agents/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def _patch_tools():
3434

3535
class OpenAIAgentsIntegration(Integration):
3636
identifier = "openai_agents"
37-
origin = f"auto.ai.{identifier}"
3837

3938
@staticmethod
4039
def setup_once():
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SPAN_ORIGIN = "auto.ai.openai_agents"

sentry_sdk/integrations/openai_agents/spans/agent_workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sentry_sdk
2+
3+
from ..consts import SPAN_ORIGIN
24
from ..utils import _get_start_span_function
35

46
from typing import TYPE_CHECKING
@@ -14,7 +16,7 @@ def agent_workflow_span(*args, **kwargs):
1416
# Create a transaction or a span if an transaction is already active
1517
span = _get_start_span_function()(
1618
name=f"{agent.name} workflow",
17-
origin=sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration.origin,
19+
origin=SPAN_ORIGIN,
1820
)
1921

2022
return span

sentry_sdk/integrations/openai_agents/spans/ai_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sentry_sdk
22
from sentry_sdk.consts import OP, SPANDATA
33

4+
from ..consts import SPAN_ORIGIN
45
from ..utils import (
56
_set_agent_data,
67
_set_input_data,
@@ -21,7 +22,7 @@ def ai_client_span(agent, get_response_kwargs):
2122
span = sentry_sdk.start_span(
2223
op=OP.GEN_AI_CHAT,
2324
description=f"chat {agent.model}",
24-
origin=sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration.origin,
25+
origin=SPAN_ORIGIN,
2526
)
2627
# TODO-anton: remove hardcoded stuff and replace something that also works for embedding and so on
2728
span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "chat")

sentry_sdk/integrations/openai_agents/spans/execute_tool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from sentry_sdk.consts import OP, SPANDATA
33
from sentry_sdk.scope import should_send_default_pii
44

5+
from ..consts import SPAN_ORIGIN
56
from ..utils import _set_agent_data
67

78
from typing import TYPE_CHECKING
@@ -16,7 +17,7 @@ def execute_tool_span(tool, *args, **kwargs):
1617
span = sentry_sdk.start_span(
1718
op=OP.GEN_AI_EXECUTE_TOOL,
1819
name=f"execute_tool {tool.name}",
19-
origin=sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration.origin,
20+
origin=SPAN_ORIGIN,
2021
)
2122

2223
span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "execute_tool")

sentry_sdk/integrations/openai_agents/spans/invoke_agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sentry_sdk
22
from sentry_sdk.consts import OP, SPANDATA
33

4+
from ..consts import SPAN_ORIGIN
45
from ..utils import _set_agent_data
56

67
from typing import TYPE_CHECKING
@@ -15,7 +16,7 @@ def invoke_agent_span(context, agent):
1516
span = sentry_sdk.start_span(
1617
op=OP.GEN_AI_INVOKE_AGENT,
1718
name=f"invoke_agent {agent.name}",
18-
origin=sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration.origin,
19+
origin=SPAN_ORIGIN,
1920
)
2021
span.__enter__()
2122

0 commit comments

Comments
 (0)