You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're getting exceptions when trying to connect to postgres DBs with psycopg in our code with ddtrace enabled.
From looking at the code, I think the problem is in https://github.com/DataDog/dd-trace-py/blob/main/ddtrace/ext/sql.py. If psycopg2 is imported after psycopg, then parse_pg_dsn is set to the psycopg2 implementation. That implementation, however, can't handle newer DSN parameters like sslcertmode and crashes when a DB connection is attempted with psycopg.
One possible fix would be to have separate versions of parse_pg_dsn for the two versions of psycopg, and have callers use the correct one based on the version of the connection they're using. I've attempted to implement this in #9415.
Summary of problem
We're getting exceptions when trying to connect to postgres DBs with
psycopg
in our code with ddtrace enabled.From looking at the code, I think the problem is in https://github.com/DataDog/dd-trace-py/blob/main/ddtrace/ext/sql.py. If
psycopg2
is imported afterpsycopg
, thenparse_pg_dsn
is set to thepsycopg2
implementation. That implementation, however, can't handle newer DSN parameters likesslcertmode
and crashes when a DB connection is attempted withpsycopg
.One possible fix would be to have separate versions of
parse_pg_dsn
for the two versions ofpsycopg
, and have callers use the correct one based on the version of the connection they're using. I've attempted to implement this in#9415.
Which version of dd-trace-py are you using?
1.20.18
Which version of pip are you using?
23.2.1
Which libraries and their versions are you using?
The relevant dependencies are:
How can we reproduce your problem?
docker-compose up -d
docker-compose exec python /bin/bash
pip install psycopg2==2.9.9 psycopg[binary]==3.1.19 ddtrace==1.20.18
python3
, then the following commands in the repl:What is the result that you get?
What is the result that you expected?
No error.
The text was updated successfully, but these errors were encountered: