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

Django ASGI based async views do not create Transactions #3142

Closed
antonpirker opened this issue Jun 7, 2024 · 1 comment · Fixed by #3180
Closed

Django ASGI based async views do not create Transactions #3142

antonpirker opened this issue Jun 7, 2024 · 1 comment · Fixed by #3180
Assignees

Comments

@antonpirker
Copy link
Member

antonpirker commented Jun 7, 2024

If there is an async view in Django then a transaction should be created for that view.

It seems that this is not the case right now: https://github.com/getsentry/sentry-python/blob/antonpirker/trace-origin-in-integrations/tests/integrations/django/asgi/test_asgi.py#L340

The view triggered in the linked test above should create a transaction.

There was a change in Django that we missed: #3141

We need to make sure that async views in Django emit transactions:

  • when run with Django channels (channels.http.AsgiHandler is monkey patched to start transactions)
  • when running with Djangos own ASGI handler (django.core.handlers.asgi.ASGIHandler only available in Django 3.0+)

Make sure this works in old Django (<3.0) and also newer Djangos. When checking newer Djangos make sure it works when using Channels or Djangos built in ASGI handler.

@antonpirker antonpirker added this to the Django update milestone Jun 7, 2024
@szokeasaurusrex szokeasaurusrex self-assigned this Jun 10, 2024
@szokeasaurusrex
Copy link
Member

szokeasaurusrex commented Jun 10, 2024

Looks like the problem is only for sync views on async applications

Update: issue appears to be the same for both, I likely had changed something more than just async/sync when I reached this conclusion

szokeasaurusrex added a commit to szokeasaurusrex/issue-reproductions that referenced this issue Jun 11, 2024
sentrivana pushed a commit that referenced this issue Jun 19, 2024
Cleaning up the ASGI tests for Django. Making sure it is always `wait()`ed for the application to finish and also made the tests a bit more readable and removed some useless asserts.

Fixes #3142
arjennienhuis pushed a commit to arjennienhuis/sentry-python that referenced this issue Sep 30, 2024
Cleaning up the ASGI tests for Django. Making sure it is always `wait()`ed for the application to finish and also made the tests a bit more readable and removed some useless asserts.

Fixes getsentry#3142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants