diff options
author | Richard van der Hoff <richard@matrix.org> | 2022-01-07 11:53:28 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2022-01-07 11:53:28 +0000 |
commit | 99e7fb1d52204a7b7cae9f2d9e0a51e1febf8e01 (patch) | |
tree | a4a3885698b5284f82c9343fc2d1c5ec7056e9c9 /synapse | |
parent | Merge branch 'release-v1.50' into matrix-org-hotfixes (diff) | |
download | synapse-99e7fb1d52204a7b7cae9f2d9e0a51e1febf8e01.tar.xz |
Wrap connection.commit with OpenTracing
This is an attempt to diagnose poor apdex levels, per https://github.com/matrix-org/internal-config/issues/1181
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/storage/database.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 2cacc7dd6c..3f848ca86f 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -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( |