summary refs log tree commit diff
path: root/synapse/util/logcontext.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/util/logcontext.py')
-rw-r--r--synapse/util/logcontext.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py
index c20c89aa8f..d528ced55a 100644
--- a/synapse/util/logcontext.py
+++ b/synapse/util/logcontext.py
@@ -69,6 +69,9 @@ class LoggingContext(object):
         def stop(self):
             pass
 
+        def add_database_transaction(self, duration_ms):
+            pass
+
     sentinel = Sentinel()
 
     def __init__(self, name=None):
@@ -76,6 +79,8 @@ class LoggingContext(object):
         self.name = name
         self.ru_stime = 0.
         self.ru_utime = 0.
+        self.db_txn_count = 0
+        self.db_txn_duration = 0.
         self.usage_start = None
         self.main_thread = threading.current_thread()
 
@@ -171,6 +176,10 @@ class LoggingContext(object):
 
         return ru_utime, ru_stime
 
+    def add_database_transaction(self, duration_ms):
+        self.db_txn_count += 1
+        self.db_txn_duration += duration_ms / 1000.
+
 
 class LoggingContextFilter(logging.Filter):
     """Logging filter that adds values from the current logging context to each