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 11from functools import wraps
22
3+ import sentry_sdk .utils
34from sentry_sdk import start_span
45from sentry_sdk .tracing import Span
56from sentry_sdk .utils import ContextVar
@@ -36,8 +37,18 @@ def wrapped(*args, **kwargs):
3637 return f (* args , ** kwargs )
3738 else :
3839 _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 )
4152 return res
4253
4354 return wrapped
Original file line number Diff line number Diff line change 33
44import sentry_sdk
55from 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
77from sentry_sdk .consts import OP , SPANDATA
88from sentry_sdk .integrations ._ai_common import set_data_normalized
99from sentry_sdk .scope import should_send_default_pii
Original file line number Diff line number Diff line change 22
33from sentry_sdk import consts
44from 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
66from sentry_sdk .consts import SPANDATA
77from sentry_sdk .integrations ._ai_common import set_data_normalized
88
You can’t perform that action at this time.
0 commit comments