Skip to content

Commit f801578

Browse files
authored
ref(chalice): Use new scopes API (#2883)
1 parent a354078 commit f801578

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

sentry_sdk/integrations/chalice.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from functools import wraps
33

4-
from sentry_sdk.hub import Hub
4+
import sentry_sdk
55
from sentry_sdk.integrations import Integration, DidNotEnable
66
from sentry_sdk.integrations.aws_lambda import _make_request_event_processor
77
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
@@ -33,10 +33,9 @@
3333
class 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

Comments
 (0)