Skip to content

Commit 0e66448

Browse files
committed
huggingface_hub: stop setting http transaction status on AI errors
1 parent fc83474 commit 0e66448

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

sentry_sdk/integrations/huggingface_hub.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import sys
21
import inspect
2+
import sys
33
from functools import wraps
4+
from typing import TYPE_CHECKING
45

56
import sentry_sdk
67
from sentry_sdk.ai.monitoring import record_token_usage
78
from sentry_sdk.ai.utils import set_data_normalized
8-
from sentry_sdk.consts import OP, SPANDATA
9+
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
910
from sentry_sdk.integrations import DidNotEnable, Integration
1011
from sentry_sdk.scope import should_send_default_pii
11-
from sentry_sdk.tracing_utils import set_span_errored
1212
from sentry_sdk.utils import (
1313
capture_internal_exceptions,
1414
event_from_exception,
1515
reraise,
1616
)
1717

18-
from typing import TYPE_CHECKING
19-
2018
if TYPE_CHECKING:
2119
from typing import Any, Callable, Iterable
2220

@@ -53,8 +51,6 @@ def setup_once() -> None:
5351

5452

5553
def _capture_exception(exc: "Any") -> None:
56-
set_span_errored()
57-
5854
event, hint = event_from_exception(
5955
exc,
6056
client_options=sentry_sdk.get_client().options,
@@ -131,6 +127,7 @@ def new_huggingface_task(*args: "Any", **kwargs: "Any") -> "Any":
131127
exc_info = sys.exc_info()
132128
with capture_internal_exceptions():
133129
_capture_exception(e)
130+
span.set_status(SPANSTATUS.INTERNAL_ERROR)
134131
span.__exit__(None, None, None)
135132
reraise(*exc_info)
136133

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
import re
2+
from typing import TYPE_CHECKING
13
from unittest import mock
4+
25
import pytest
3-
import re
46
import responses
5-
67
from huggingface_hub import InferenceClient
78

89
import sentry_sdk
9-
from sentry_sdk.utils import package_version
1010
from sentry_sdk.integrations.huggingface_hub import HuggingfaceHubIntegration
11-
12-
from typing import TYPE_CHECKING
11+
from sentry_sdk.utils import package_version
1312

1413
try:
1514
from huggingface_hub.utils._errors import HfHubHTTPError
@@ -834,8 +833,6 @@ def test_span_status_error(
834833
assert span["status"] == "internal_error"
835834
assert span["tags"]["status"] == "internal_error"
836835

837-
assert transaction["contexts"]["trace"]["status"] == "internal_error"
838-
839836

840837
@pytest.mark.httpx_mock(assert_all_requests_were_expected=False)
841838
@pytest.mark.parametrize("send_default_pii", [True, False])

0 commit comments

Comments
 (0)