11import sys
22from functools import wraps
33
4- from sentry_sdk . hub import Hub
4+ import sentry_sdk
55from sentry_sdk .integrations import Integration , DidNotEnable
66from sentry_sdk .integrations .aws_lambda import _make_request_event_processor
77from sentry_sdk .tracing import TRANSACTION_SOURCE_COMPONENT
3333class EventSourceHandler (ChaliceEventSourceHandler ): # type: ignore
3434 def __call__ (self , event , context ):
3535 # type: (Any, Any) -> Any
36- hub = Hub .current
37- client = hub .client # type: Any
36+ client = sentry_sdk .get_client ()
3837
39- with hub . push_scope () as scope :
38+ with sentry_sdk . isolation_scope () as scope :
4039 with capture_internal_exceptions ():
4140 configured_time = context .get_remaining_time_in_millis ()
4241 scope .add_event_processor (
@@ -51,8 +50,8 @@ def __call__(self, event, context):
5150 client_options = client .options ,
5251 mechanism = {"type" : "chalice" , "handled" : False },
5352 )
54- hub .capture_event (event , hint = hint )
55- hub .flush ()
53+ sentry_sdk .capture_event (event , hint = hint )
54+ client .flush ()
5655 reraise (* exc_info )
5756
5857
@@ -61,9 +60,8 @@ def _get_view_function_response(app, view_function, function_args):
6160 @wraps (view_function )
6261 def wrapped_view_function (** function_args ):
6362 # 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 :
6765 with capture_internal_exceptions ():
6866 configured_time = app .lambda_context .get_remaining_time_in_millis ()
6967 scope .set_transaction_name (
@@ -89,8 +87,8 @@ def wrapped_view_function(**function_args):
8987 client_options = client .options ,
9088 mechanism = {"type" : "chalice" , "handled" : False },
9189 )
92- hub .capture_event (event , hint = hint )
93- hub .flush ()
90+ sentry_sdk .capture_event (event , hint = hint )
91+ client .flush ()
9492 raise
9593
9694 return wrapped_view_function # type: ignore
0 commit comments