mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 02:24:49 -04:00
Track the time spent in the database per request.
and track the number of transactions that request started.
This commit is contained in:
parent
f7a1cdbbc6
commit
6a5ff5f223
5 changed files with 38 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue