summary refs log tree commit diff
path: root/synapse/storage/database.py
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-01-07 11:25:49 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-01-07 11:25:49 +0000
commit24c131d20f6a8d294df73631ed19a1290ade52f5 (patch)
tree33e10bf587321399408bf8f77fcf54470d97c52e /synapse/storage/database.py
parentMerge branch 'release-v1.50' into matrix-org-hotfixes (diff)
downloadsynapse-24c131d20f6a8d294df73631ed19a1290ade52f5.tar.xz
Trace connection commit with OpenTracing
Diffstat (limited to '')
-rw-r--r--synapse/storage/database.py12
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")
             )