File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 1+ Report OpenTracing spans for database activity.
Original file line number Diff line number Diff line change @@ -91,12 +91,18 @@ def make_pool(
9191 db_args = dict (db_config .config .get ("args" , {}))
9292 db_args .setdefault ("cp_reconnect" , True )
9393
94+ def _on_new_connection (conn ):
95+ # Ensure we have a logging context so we can correctly track queries,
96+ # etc.
97+ with LoggingContext ("db.on_new_connection" ):
98+ engine .on_new_connection (
99+ LoggingDatabaseConnection (conn , engine , "on_new_connection" )
100+ )
101+
94102 return adbapi .ConnectionPool (
95103 db_config .config ["name" ],
96104 cp_reactor = reactor ,
97- cp_openfun = lambda conn : engine .on_new_connection (
98- LoggingDatabaseConnection (conn , engine , "on_new_connection" )
99- ),
105+ cp_openfun = _on_new_connection ,
100106 ** db_args ,
101107 )
102108
You can’t perform that action at this time.
0 commit comments