Potential N+1 query issue with capture_exception in Sentry SDK for Django after upgrading to 2.17.0 #3718
Unanswered
gabicavalcante
asked this question in
Q&A
Replies: 1 comment 10 replies
-
Strange, I would need more info to help you.
Can you dig a bit more into what kind of query it is that increased? And also make sure that that does not happen if you disable Sentry? |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone! I recently upgraded from sentry-sdk version 1.4.3 to 2.17.0 for my Django project and noticed a curious behavior. When I use capture_exception with certain exceptions, it seems to kick off extra database queries, especially when Django model instances are involved. It’s almost like it’s adding a bit of an N+1 query pattern, which I hadn’t seen in the older version.
Here’s a little example of what I’m seeing:
This is a legacy codebase we’re slowly refactoring, but I found it interesting because this issue wasn’t happening before the upgrade. We actually have an assert_num_queries test to keep an eye on performance, and thanks to that test, we caught the increase: the function jumped from 10 queries to 23 after the upgrade! Our current fix was to keep only the
logger.exception
with the data we think is critical to know about the issue.Has anyone else noticed this, or maybe found a workaround? It would be great to hear any thoughts! Thanks!
Beta Was this translation helpful? Give feedback.
All reactions