1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index 2cacc7dd6c..d855ad4938 100644
--- a/synapse/storage/database.py
+++ b/synapse/storage/database.py
@@ -104,6 +104,18 @@ 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.
+ real_commit = conn.commit
+
+ def traced_commit(*args, **kwargs):
+ with opentracing.start_active_span(
+ "db.conn.commit"
+ ):
+ real_commit(*args, **kwargs)
+
+ conn.commit = traced_commit
+
engine.on_new_connection(
LoggingDatabaseConnection(conn, engine, "on_new_connection")
)
|