mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:46:02 -04:00
Track db txn time in millisecs
... to reduce the amount of floating-point foo we do.
This commit is contained in:
parent
44a498418c
commit
6324b65f08
4 changed files with 17 additions and 10 deletions
|
@ -59,7 +59,7 @@ class LoggingContext(object):
|
|||
|
||||
__slots__ = [
|
||||
"previous_context", "name", "ru_stime", "ru_utime",
|
||||
"db_txn_count", "db_txn_duration", "usage_start", "usage_end",
|
||||
"db_txn_count", "db_txn_duration_ms", "usage_start", "usage_end",
|
||||
"main_thread", "alive",
|
||||
"request", "tag",
|
||||
]
|
||||
|
@ -97,7 +97,10 @@ class LoggingContext(object):
|
|||
self.ru_stime = 0.
|
||||
self.ru_utime = 0.
|
||||
self.db_txn_count = 0
|
||||
self.db_txn_duration = 0.
|
||||
|
||||
# ms spent waiting for db txns, excluding scheduling time
|
||||
self.db_txn_duration_ms = 0
|
||||
|
||||
self.usage_start = None
|
||||
self.usage_end = None
|
||||
self.main_thread = threading.current_thread()
|
||||
|
@ -205,7 +208,7 @@ class LoggingContext(object):
|
|||
|
||||
def add_database_transaction(self, duration_ms):
|
||||
self.db_txn_count += 1
|
||||
self.db_txn_duration += duration_ms / 1000.
|
||||
self.db_txn_duration_ms += duration_ms
|
||||
|
||||
|
||||
class LoggingContextFilter(logging.Filter):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue