1
0

Compare commits

...

6 Commits

Author SHA1 Message Date
Olivier Wilkinson (reivilibre)
b987ccb766 Use getattr() rather than __getattr__() 2022-01-07 11:42:38 +00:00
Olivier Wilkinson (reivilibre)
6b6122d632 Whoops 2022-01-07 11:41:15 +00:00
Olivier Wilkinson (reivilibre)
f69d2fcac1 Use a nasty wrapper class 2022-01-07 11:40:40 +00:00
Olivier Wilkinson (reivilibre)
f53801b2b5 Use setattr because direct assignment fails 2022-01-07 11:38:31 +00:00
Olivier Wilkinson (reivilibre)
fd396fdaae Use fancy trace function instead 2022-01-07 11:28:14 +00:00
Olivier Wilkinson (reivilibre)
24c131d20f Trace connection commit with OpenTracing 2022-01-07 11:25:49 +00:00

View File

@@ -50,6 +50,7 @@ from synapse.logging.context import (
current_context,
make_deferred_yieldable,
)
from synapse.logging.opentracing import trace
from synapse.metrics import register_threadpool
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.storage.background_updates import BackgroundUpdater
@@ -104,8 +105,20 @@ def make_pool(
# Ensure we have a logging context so we can correctly track queries,
# etc.
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.
class NastyConnectionWrapper:
def __init__(self, connection):
self._connection = connection
self.commit = trace(connection.commit, "db.conn.commit")
def __getattr__(self, item):
return getattr(self._connection, item)
engine.on_new_connection(
LoggingDatabaseConnection(conn, engine, "on_new_connection")
LoggingDatabaseConnection(
NastyConnectionWrapper(conn), engine, "on_new_connection"
)
)
connection_pool = adbapi.ConnectionPool(