File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
sentry_sdk/integrations/django Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -717,8 +717,18 @@ def _set_db_data(span, cursor_or_db):
717717 connection_params = cursor_or_db .connection .get_dsn_parameters ()
718718 else :
719719 try :
720- # psycopg3
721- connection_params = cursor_or_db .connection .info .get_parameters ()
720+ # psycopg3, only extract needed params as get_parameters
721+ # can be slow because of the additional logic to filter out default
722+ # values
723+ connection_params = {
724+ "dbname" : cursor_or_db .connection .info .dbname ,
725+ "port" : cursor_or_db .connection .info .port ,
726+ }
727+ # PGhost returns host or base dir of UNIX socket as an absolute path
728+ # starting with /, use it only when it contains host
729+ pg_host = cursor_or_db .connection .info .host
730+ if pg_host and not pg_host .startswith ("/" ):
731+ connection_params ["host" ] = pg_host
722732 except Exception :
723733 connection_params = db .get_connection_params ()
724734
You can’t perform that action at this time.
0 commit comments