File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
from functools import wraps
2
2
3
+ import sentry_sdk .utils
3
4
from sentry_sdk import start_span
4
5
from sentry_sdk .tracing import Span
5
6
from sentry_sdk .utils import ContextVar
@@ -36,8 +37,18 @@ def wrapped(*args, **kwargs):
36
37
return f (* args , ** kwargs )
37
38
else :
38
39
_ai_pipeline_name .set (description )
39
- res = f (* args , ** kwargs )
40
- _ai_pipeline_name .set (None )
40
+ try :
41
+ res = f (* args , ** kwargs )
42
+ except Exception as e :
43
+ event , hint = sentry_sdk .utils .event_from_exception (
44
+ e ,
45
+ client_options = sentry_sdk .get_client ().options ,
46
+ mechanism = {"type" : "ai_monitoring" , "handled" : False },
47
+ )
48
+ sentry_sdk .capture_event (event , hint = hint )
49
+ raise e from None
50
+ finally :
51
+ _ai_pipeline_name .set (None )
41
52
return res
42
53
43
54
return wrapped
Original file line number Diff line number Diff line change 3
3
4
4
import sentry_sdk
5
5
from sentry_sdk ._types import TYPE_CHECKING
6
- from sentry_sdk .ai_analytics import set_ai_pipeline_name , record_token_usage
6
+ from sentry_sdk .ai_monitoring import set_ai_pipeline_name , record_token_usage
7
7
from sentry_sdk .consts import OP , SPANDATA
8
8
from sentry_sdk .integrations ._ai_common import set_data_normalized
9
9
from sentry_sdk .scope import should_send_default_pii
Original file line number Diff line number Diff line change 2
2
3
3
from sentry_sdk import consts
4
4
from sentry_sdk ._types import TYPE_CHECKING
5
- from sentry_sdk .ai_analytics import record_token_usage
5
+ from sentry_sdk .ai_monitoring import record_token_usage
6
6
from sentry_sdk .consts import SPANDATA
7
7
from sentry_sdk .integrations ._ai_common import set_data_normalized
8
8
You can’t perform that action at this time.
0 commit comments