@@ -392,13 +392,11 @@ def _set_transaction_name_and_source(scope, transaction_style, request):
392
392
pass
393
393
394
394
395
+ @ensure_integration_enabled (DjangoIntegration )
395
396
def _before_get_response (request ):
396
397
# type: (WSGIRequest) -> None
397
398
integration = sentry_sdk .get_client ().get_integration (DjangoIntegration )
398
399
399
- if integration is None :
400
- return
401
-
402
400
_patch_drf ()
403
401
404
402
scope = Scope .get_current_scope ()
@@ -423,10 +421,11 @@ def _attempt_resolve_again(request, scope, transaction_style):
423
421
_set_transaction_name_and_source (scope , transaction_style , request )
424
422
425
423
424
+ @ensure_integration_enabled (DjangoIntegration )
426
425
def _after_get_response (request ):
427
426
# type: (WSGIRequest) -> None
428
427
integration = sentry_sdk .get_client ().get_integration (DjangoIntegration )
429
- if integration is None or integration .transaction_style != "url" :
428
+ if integration .transaction_style != "url" :
430
429
return
431
430
432
431
scope = Scope .get_current_scope ()
@@ -492,21 +491,22 @@ def wsgi_request_event_processor(event, hint):
492
491
return wsgi_request_event_processor
493
492
494
493
494
+ @ensure_integration_enabled (DjangoIntegration )
495
495
def _got_request_exception (request = None , ** kwargs ):
496
496
# type: (WSGIRequest, **Any) -> None
497
497
client = sentry_sdk .get_client ()
498
498
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 )
510
510
511
511
512
512
class DjangoRequestExtractor (RequestExtractor ):
0 commit comments