File tree Expand file tree Collapse file tree
sentry_sdk/integrations/django Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111import inspect
1212from typing import TYPE_CHECKING
1313
14+ from django import VERSION as DJANGO_VERSION
1415from django .core .handlers .wsgi import WSGIRequest
1516
1617import sentry_sdk
@@ -96,8 +97,11 @@ async def sentry_patched_asgi_handler(
9697 unsafe_context_data = True ,
9798 span_origin = DjangoIntegration .origin ,
9899 http_methods_to_capture = integration .http_methods_to_capture ,
100+ # From Django 5.1 onwards, ASGI request.path is taken directly from scope["path"] without prepending scope["root_path"].
101+ # Assume that scope["path"] includes scope["root_path"] for these versions, as otherwise request.path is also incorrect.
102+ # https://github.com/django/django/commit/bcd255cd5ca0a1e686d276cca71f45ec400d84a2
103+ path_includes_root_path = DJANGO_VERSION >= (5 , 1 ),
99104 )._run_asgi3
100-
101105 return await middleware (scope , receive , send )
102106
103107 cls .__call__ = sentry_patched_asgi_handler
You can’t perform that action at this time.
0 commit comments