getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
38.94k stars 4.17k forks source link

Instrument database connection calls in Django #30009

Closed chdsbd closed 2 years ago

chdsbd commented 2 years ago

Problem Statement

Sentry instruments calls to cursor.execute and cursor.executemany, but misses other database calls when Django opens a connection.

When Django opens a connection it makes a few network calls that would be useful to record.

Solution Brainstorm

Instrument Django calls to DatabaseWrapper.connect so traces show all queries made to the database.

https://github.com/django/django/blob/8d9827c06ce1592cca111e7eafb9ebe0153104ef/django/db/backends/base/base.py#L197-L200

chdsbd commented 2 years ago

This should be in sentry-python.