update to more consistently use seconds in any metrics or logging

This commit is contained in:
Amber Brown 2018-05-28 19:39:27 +10:00
parent 5c40ce3777
commit 3ef5cd74a6
4 changed files with 38 additions and 38 deletions

View file

@ -74,7 +74,7 @@ class Measure(object):
self.created_context = False
def __enter__(self):
self.start = self.clock.time_msec()
self.start = self.clock.time()
self.start_context = LoggingContext.current_context()
if not self.start_context:
self.start_context = LoggingContext("Measure")
@ -90,7 +90,7 @@ class Measure(object):
if isinstance(exc_type, Exception) or not self.start_context:
return
duration = self.clock.time_msec() - self.start
duration = self.clock.time() - self.start
block_counter.labels(self.name).inc()
block_timer.labels(self.name).inc(duration)
@ -114,9 +114,9 @@ class Measure(object):
block_ru_stime.labels(self.name).inc(ru_stime - self.ru_stime)
block_db_txn_count.labels(self.name).inc(context.db_txn_count - self.db_txn_count)
block_db_txn_duration.labels(self.name).inc(
(context.db_txn_duration_ms - self.db_txn_duration_ms) / 1000.)
context.db_txn_duration_sec - self.db_txn_duration_sec)
block_db_sched_duration.labels(self.name).inc(
(context.db_sched_duration_ms - self.db_sched_duration_ms) / 1000.)
context.db_sched_duration_sec - self.db_sched_duration_sec)
if self.created_context:
self.start_context.__exit__(exc_type, exc_val, exc_tb)