Skip to content

Commit a1fc21f

Browse files
committed
fix(pyramid): Set transaction name eagerly
This is needed for APM and also fixes getsentry#683
1 parent 5f9a350 commit a1fc21f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sentry_sdk/integrations/pyramid.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,17 @@ def sentry_patched_handle_request(self, request, *args, **kwargs):
7272
# type: (Any, Request, *Any, **Any) -> Response
7373
hub = Hub.current
7474
integration = hub.get_integration(PyramidIntegration)
75+
7576
if integration is not None:
7677
with hub.configure_scope() as scope:
78+
try:
79+
if integration.transaction_style == "route_name":
80+
scope.transaction = request.matched_route.name
81+
elif integration.transaction_style == "route_pattern":
82+
scope.transaction = request.matched_route.pattern
83+
except Exception:
84+
pass
85+
7786
scope.add_event_processor(
7887
_make_event_processor(weakref.ref(request), integration)
7988
)
@@ -196,14 +205,6 @@ def event_processor(event, hint):
196205
if request is None:
197206
return event
198207

199-
try:
200-
if integration.transaction_style == "route_name":
201-
event["transaction"] = request.matched_route.name
202-
elif integration.transaction_style == "route_pattern":
203-
event["transaction"] = request.matched_route.pattern
204-
except Exception:
205-
pass
206-
207208
with capture_internal_exceptions():
208209
PyramidRequestExtractor(request).extract_into_event(event)
209210

0 commit comments

Comments
 (0)