@@ -392,13 +392,11 @@ def _set_transaction_name_and_source(scope, transaction_style, request):
392392 pass
393393
394394
395+ @ensure_integration_enabled (DjangoIntegration )
395396def _before_get_response (request ):
396397 # type: (WSGIRequest) -> None
397398 integration = sentry_sdk .get_client ().get_integration (DjangoIntegration )
398399
399- if integration is None :
400- return
401-
402400 _patch_drf ()
403401
404402 scope = Scope .get_current_scope ()
@@ -423,10 +421,11 @@ def _attempt_resolve_again(request, scope, transaction_style):
423421 _set_transaction_name_and_source (scope , transaction_style , request )
424422
425423
424+ @ensure_integration_enabled (DjangoIntegration )
426425def _after_get_response (request ):
427426 # type: (WSGIRequest) -> None
428427 integration = sentry_sdk .get_client ().get_integration (DjangoIntegration )
429- if integration is None or integration .transaction_style != "url" :
428+ if integration .transaction_style != "url" :
430429 return
431430
432431 scope = Scope .get_current_scope ()
@@ -492,21 +491,22 @@ def wsgi_request_event_processor(event, hint):
492491 return wsgi_request_event_processor
493492
494493
494+ @ensure_integration_enabled (DjangoIntegration )
495495def _got_request_exception (request = None , ** kwargs ):
496496 # type: (WSGIRequest, **Any) -> None
497497 client = sentry_sdk .get_client ()
498498 integration = client .get_integration (DjangoIntegration )
499- if integration is not None :
500- if request is not None and integration .transaction_style == "url" :
501- scope = Scope .get_current_scope ()
502- _attempt_resolve_again (request , scope , integration .transaction_style )
503-
504- event , hint = event_from_exception (
505- sys .exc_info (),
506- client_options = client .options ,
507- mechanism = {"type" : "django" , "handled" : False },
508- )
509- sentry_sdk .capture_event (event , hint = hint )
499+
500+ if request is not None and integration .transaction_style == "url" :
501+ scope = Scope .get_current_scope ()
502+ _attempt_resolve_again (request , scope , integration .transaction_style )
503+
504+ event , hint = event_from_exception (
505+ sys .exc_info (),
506+ client_options = client .options ,
507+ mechanism = {"type" : "django" , "handled" : False },
508+ )
509+ sentry_sdk .capture_event (event , hint = hint )
510510
511511
512512class DjangoRequestExtractor (RequestExtractor ):
0 commit comments