1
1
import sys
2
2
from functools import wraps
3
3
4
- from sentry_sdk . hub import Hub
4
+ import sentry_sdk
5
5
from sentry_sdk .integrations import Integration , DidNotEnable
6
6
from sentry_sdk .integrations .aws_lambda import _make_request_event_processor
7
7
from sentry_sdk .tracing import TRANSACTION_SOURCE_COMPONENT
33
33
class EventSourceHandler (ChaliceEventSourceHandler ): # type: ignore
34
34
def __call__ (self , event , context ):
35
35
# type: (Any, Any) -> Any
36
- hub = Hub .current
37
- client = hub .client # type: Any
36
+ client = sentry_sdk .get_client ()
38
37
39
- with hub . push_scope () as scope :
38
+ with sentry_sdk . isolation_scope () as scope :
40
39
with capture_internal_exceptions ():
41
40
configured_time = context .get_remaining_time_in_millis ()
42
41
scope .add_event_processor (
@@ -51,8 +50,8 @@ def __call__(self, event, context):
51
50
client_options = client .options ,
52
51
mechanism = {"type" : "chalice" , "handled" : False },
53
52
)
54
- hub .capture_event (event , hint = hint )
55
- hub .flush ()
53
+ sentry_sdk .capture_event (event , hint = hint )
54
+ client .flush ()
56
55
reraise (* exc_info )
57
56
58
57
@@ -61,9 +60,8 @@ def _get_view_function_response(app, view_function, function_args):
61
60
@wraps (view_function )
62
61
def wrapped_view_function (** function_args ):
63
62
# type: (**Any) -> Any
64
- hub = Hub .current
65
- client = hub .client # type: Any
66
- with hub .push_scope () as scope :
63
+ client = sentry_sdk .get_client ()
64
+ with sentry_sdk .isolation_scope () as scope :
67
65
with capture_internal_exceptions ():
68
66
configured_time = app .lambda_context .get_remaining_time_in_millis ()
69
67
scope .set_transaction_name (
@@ -89,8 +87,8 @@ def wrapped_view_function(**function_args):
89
87
client_options = client .options ,
90
88
mechanism = {"type" : "chalice" , "handled" : False },
91
89
)
92
- hub .capture_event (event , hint = hint )
93
- hub .flush ()
90
+ sentry_sdk .capture_event (event , hint = hint )
91
+ client .flush ()
94
92
raise
95
93
96
94
return wrapped_view_function # type: ignore
0 commit comments