From f69d2fcac1acd813b7b46c8dd9df92bea598bb9a Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 7 Jan 2022 11:40:40 +0000 Subject: Use a nasty wrapper class --- synapse/storage/database.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'synapse/storage/database.py') diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 1c1d76520f..f713efbf90 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -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( -- cgit 1.5.1