From 9b1430e111875ac397ff67997955694259617bab Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Fri, 20 Mar 2026 09:56:55 +0100 Subject: [PATCH 1/2] fix(anthropic): Stop setting transaction to errored when child span fails --- sentry_sdk/integrations/anthropic.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sentry_sdk/integrations/anthropic.py b/sentry_sdk/integrations/anthropic.py index 9aa3825037..b7a47715a4 100644 --- a/sentry_sdk/integrations/anthropic.py +++ b/sentry_sdk/integrations/anthropic.py @@ -17,7 +17,6 @@ from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.tracing_utils import set_span_errored from sentry_sdk.utils import ( capture_internal_exceptions, event_from_exception, @@ -195,8 +194,6 @@ def setup_once() -> None: def _capture_exception(exc: "Any") -> None: - set_span_errored() - event, hint = event_from_exception( exc, client_options=sentry_sdk.get_client().options, @@ -633,7 +630,7 @@ def _sentry_patched_create_sync(f: "Any", *args: "Any", **kwargs: "Any") -> "Any exc_info = sys.exc_info() with capture_internal_exceptions(): _capture_exception(exc) - span.__exit__(None, None, None) + span.__exit__(*exc_info) reraise(*exc_info) if isinstance(result, Stream): @@ -721,7 +718,7 @@ async def _sentry_patched_create_async( exc_info = sys.exc_info() with capture_internal_exceptions(): _capture_exception(exc) - span.__exit__(None, None, None) + span.__exit__(*exc_info) reraise(*exc_info) if isinstance(result, AsyncStream): From 8fb81249b6551bcd83a5366f87b8af859325f5ee Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 7 Apr 2026 14:43:12 +0200 Subject: [PATCH 2/2] update tests --- tests/integrations/anthropic/test_anthropic.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integrations/anthropic/test_anthropic.py b/tests/integrations/anthropic/test_anthropic.py index bd9a41e701..e86f7e1fa9 100644 --- a/tests/integrations/anthropic/test_anthropic.py +++ b/tests/integrations/anthropic/test_anthropic.py @@ -2204,7 +2204,6 @@ def test_span_status_error(sentry_init, capture_events): assert error["level"] == "error" assert transaction["spans"][0]["status"] == "internal_error" assert transaction["spans"][0]["tags"]["status"] == "internal_error" - assert transaction["contexts"]["trace"]["status"] == "internal_error" assert transaction["spans"][0]["data"][SPANDATA.GEN_AI_SYSTEM] == "anthropic" assert transaction["spans"][0]["data"][SPANDATA.GEN_AI_OPERATION_NAME] == "chat" @@ -2230,7 +2229,6 @@ async def test_span_status_error_async(sentry_init, capture_events): assert error["level"] == "error" assert transaction["spans"][0]["status"] == "internal_error" assert transaction["spans"][0]["tags"]["status"] == "internal_error" - assert transaction["contexts"]["trace"]["status"] == "internal_error" assert transaction["spans"][0]["data"][SPANDATA.GEN_AI_SYSTEM] == "anthropic" assert transaction["spans"][0]["data"][SPANDATA.GEN_AI_OPERATION_NAME] == "chat"