From 24c131d20f6a8d294df73631ed19a1290ade52f5 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 7 Jan 2022 11:25:49 +0000 Subject: Trace connection commit with OpenTracing --- synapse/storage/database.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'synapse') 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") ) -- cgit 1.5.1