Skip to content

Commit

Permalink
fix(django): Fix psycopg2 detection (#2593)
Browse files Browse the repository at this point in the history
We were failing to detect built-in methods. isroutine() should cover both cases.
  • Loading branch information
sentrivana authored Dec 14, 2023
1 parent 64c42ca commit d76fa98
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def _set_db_data(span, cursor_or_db):
is_psycopg2 = (
hasattr(cursor_or_db, "connection")
and hasattr(cursor_or_db.connection, "get_dsn_parameters")
and inspect.isfunction(cursor_or_db.connection.get_dsn_parameters)
and inspect.isroutine(cursor_or_db.connection.get_dsn_parameters)
)
if is_psycopg2:
connection_params = cursor_or_db.connection.get_dsn_parameters()
Expand All @@ -706,7 +706,7 @@ def _set_db_data(span, cursor_or_db):
hasattr(cursor_or_db, "connection")
and hasattr(cursor_or_db.connection, "info")
and hasattr(cursor_or_db.connection.info, "get_parameters")
and inspect.isfunction(cursor_or_db.connection.info.get_parameters)
and inspect.isroutine(cursor_or_db.connection.info.get_parameters)
)
if is_psycopg3:
connection_params = cursor_or_db.connection.info.get_parameters()
Expand Down

0 comments on commit d76fa98

Please sign in to comment.