summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-12-08 11:52:35 +0000
committerMark Haines <mjark@negativecurvature.net>2015-12-08 11:52:35 +0000
commit219027f580774dedebf0074cf25500d424b451f3 (patch)
treeb0876351b0c892e23c81ac5a3d85f329d34df7b6 /synapse/util
parentMerge pull request #423 from matrix-org/markjh/archived_flag (diff)
parentTrack the time spent in the database per request. (diff)
downloadsynapse-219027f580774dedebf0074cf25500d424b451f3.tar.xz
Merge pull request #429 from matrix-org/markjh/db_counters
Track the time spent in the database per request.
Diffstat (limited to 'synapse/util')
-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