Skip to content

Commit 35bd5f7

Browse files
.
1 parent 36eb8d7 commit 35bd5f7

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

sentry_sdk/integrations/openai_agents/patches/agent_run.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ def _maybe_start_agent_span(
6666
current_agent = _get_current_agent(context_wrapper)
6767
if current_agent and current_agent != agent:
6868
span = getattr(context_wrapper, "_sentry_agent_span", None)
69-
if not span:
70-
return
69+
if span:
70+
update_invoke_agent_span(
71+
span=span, context=context_wrapper, agent=agent
72+
)
7173

72-
update_invoke_agent_span(span=span, context=context_wrapper, agent=agent)
73-
74-
span.__exit__(None, None, None)
75-
delattr(context_wrapper, "_sentry_agent_span")
74+
span.__exit__(None, None, None)
75+
delattr(context_wrapper, "_sentry_agent_span")
7676

7777
# Store the agent on the context wrapper so we can access it later
7878
context_wrapper._sentry_current_agent = agent

sentry_sdk/integrations/openai_agents/patches/error_tracing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import TYPE_CHECKING
33

44
import sentry_sdk
5-
from sentry_sdk.tracing_utils import set_span_errored
5+
from sentry_sdk.consts import SPANSTATUS
66

77
if TYPE_CHECKING:
88
from typing import Any
@@ -56,7 +56,7 @@ def sentry_attach_error_to_current_span(
5656
# Set the current Sentry span to errored
5757
current_span = sentry_sdk.get_current_span()
5858
if current_span is not None:
59-
set_span_errored(current_span)
59+
current_span.set_status(SPANSTATUS.INTERNAL_ERROR)
6060

6161
# Call the original function
6262
return original_attach_error(error, *args, **kwargs)

0 commit comments

Comments
 (0)