diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-12-07 17:56:11 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-12-07 17:56:11 +0000 |
commit | 6a5ff5f223c1b4311aa63574663c0335d0c6bd79 (patch) | |
tree | b0876351b0c892e23c81ac5a3d85f329d34df7b6 /synapse/util | |
parent | Merge pull request #423 from matrix-org/markjh/archived_flag (diff) | |
download | synapse-6a5ff5f223c1b4311aa63574663c0335d0c6bd79.tar.xz |
Track the time spent in the database per request.
and track the number of transactions that request started.
Diffstat (limited to '')
-rw-r--r-- | synapse/util/logcontext.py | 9 |
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 |