Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowing ASGI to use drf_request in DjangoRequestExtractor #3572

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,6 @@ def wsgi_request_event_processor(event, hint):
# We have a `asgi_request_event_processor` for this.
return event

try:
drf_request = request._sentry_drf_request_backref()
if drf_request is not None:
request = drf_request
except AttributeError:
pass

with capture_internal_exceptions():
DjangoRequestExtractor(request).extract_into_event(event)

Expand Down Expand Up @@ -530,6 +523,15 @@ def _got_request_exception(request=None, **kwargs):


class DjangoRequestExtractor(RequestExtractor):
def __init__(self, request):
try:
drf_request = request._sentry_drf_request_backref()
if drf_request is not None:
request = drf_request
except AttributeError:
pass
self.request = request

def env(self):
# type: () -> Dict[str, str]
return self.request.META
Expand Down
Loading