88except ImportError :
99 from django .core .urlresolvers import resolve
1010
11- from sentry_sdk import get_current_hub , configure_scope , capture_exception
11+ from sentry_sdk import get_current_hub , capture_exception
1212from sentry_sdk .hub import _internal_exceptions , _should_send_default_pii
1313from ._wsgi import RequestExtractor , get_client_ip
1414from . import Integration
@@ -45,10 +45,10 @@ def sentry_patched_get_response(self, request):
4545 lambda : make_event_processor (request )
4646 )
4747
48- with configure_scope () as scope :
49- scope . transaction = resolve ( request . path ). func . __name__
50-
51- return old_get_response ( self , request )
48+ try :
49+ return old_get_response ( self , request )
50+ except Exception :
51+ capture_exception ( )
5252
5353 BaseHandler .get_response = sentry_patched_get_response
5454
@@ -58,6 +58,10 @@ def _make_event_processor(self, request):
5858 client_options = get_current_hub ().client .options
5959
6060 def processor (event ):
61+ if "transaction" not in event :
62+ with _internal_exceptions ():
63+ event ["transaction" ] = resolve (request .path ).func .__name__
64+
6165 with _internal_exceptions ():
6266 DjangoRequestExtractor (request ).extract_into_event (
6367 event , client_options
0 commit comments