Skip to content

Commit dc3d352

Browse files
update django condition
1 parent eda0dec commit dc3d352

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • sentry_sdk/integrations/django

sentry_sdk/integrations/django/asgi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import inspect
1212
from typing import TYPE_CHECKING
1313

14+
from django import VERSION as DJANGO_VERSION
1415
from django.core.handlers.wsgi import WSGIRequest
1516

1617
import 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

0 commit comments

Comments
 (0)