summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-01-07 11:28:14 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-01-07 11:28:14 +0000
commitfd396fdaae37be82b070b2bb1b124d7b78922adb (patch)
tree10e4893ae128e18205f84d7776dd5be99a562d22
parentTrace connection commit with OpenTracing (diff)
downloadsynapse-fd396fdaae37be82b070b2bb1b124d7b78922adb.tar.xz
Use fancy `trace` function instead
-rw-r--r--synapse/storage/database.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index d855ad4938..319c451856 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
@@ -106,15 +107,7 @@ 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.
-            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
+            conn.commit = trace(conn.commit, "db.conn.commit")
 
             engine.on_new_connection(
                 LoggingDatabaseConnection(conn, engine, "on_new_connection")