1
0

Use a nasty wrapper class

This commit is contained in:
Olivier Wilkinson (reivilibre)
2022-01-07 11:40:40 +00:00
parent f53801b2b5
commit f69d2fcac1

View File

@@ -107,10 +107,18 @@ def make_pool(
with LoggingContext("db.on_new_connection"):
# HACK Patch the connection's commit function so that we can see
# how long it's taking from Jaeger.
setattr(conn, "commit", trace(conn.commit, "db.conn.commit"))
class NastyConnectionWrapper:
def __init__(self, connection):
self._connection = connection
self.commit = trace(conn.commit, "db.conn.commit")
def __getattr__(self, item):
return self._connection.__getattr__(item)
engine.on_new_connection(
LoggingDatabaseConnection(conn, engine, "on_new_connection")
LoggingDatabaseConnection(
NastyConnectionWrapper(conn), engine, "on_new_connection"
)
)
connection_pool = adbapi.ConnectionPool(