Skip to content
Closed
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
10 changes: 7 additions & 3 deletions sentry_sdk/integrations/huggingface_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import sentry_sdk
from sentry_sdk.ai.monitoring import record_token_usage
from sentry_sdk.ai.utils import set_data_normalized
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.tracing_utils import set_span_errored
from sentry_sdk.tracing_utils import get_current_span
from sentry_sdk.utils import (
capture_internal_exceptions,
event_from_exception,
Expand Down Expand Up @@ -53,7 +53,11 @@ def setup_once() -> None:


def _capture_exception(exc: "Any") -> None:
set_span_errored()
# Only mark the current AI span as errored; do not propagate to the
# containing HTTP transaction. (fixes #5793)
span = get_current_span()
if span is not None:
span.set_status(SPANSTATUS.INTERNAL_ERROR)

event, hint = event_from_exception(
exc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,9 @@ def test_span_status_error(
assert span["status"] == "internal_error"
assert span["tags"]["status"] == "internal_error"

assert transaction["contexts"]["trace"]["status"] == "internal_error"
# The huggingface_hub integration must NOT set the transaction status to
# internal_error — only the inner span should be errored. (fixes #5793)
assert transaction["contexts"]["trace"]["status"] != "internal_error"


@pytest.mark.httpx_mock(assert_all_requests_were_expected=False)
Expand Down