mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Don't spew errors because we can't save metrics (#3563)
This commit is contained in:
parent
ba6477feac
commit
95ccb6e2ec
1
changelog.d/3548.bugfix
Normal file
1
changelog.d/3548.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Catch failures saving metrics captured by Measure, and instead log the faulty metrics information for further analysis.
|
@ -99,6 +99,17 @@ class ContextResourceUsage(object):
|
|||||||
self.db_sched_duration_sec = 0
|
self.db_sched_duration_sec = 0
|
||||||
self.evt_db_fetch_count = 0
|
self.evt_db_fetch_count = 0
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return ("<ContextResourceUsage ru_stime='%r', ru_utime='%r', "
|
||||||
|
"db_txn_count='%r', db_txn_duration_sec='%r', "
|
||||||
|
"db_sched_duration_sec='%r', evt_db_fetch_count='%r'>") % (
|
||||||
|
self.ru_stime,
|
||||||
|
self.ru_utime,
|
||||||
|
self.db_txn_count,
|
||||||
|
self.db_txn_duration_sec,
|
||||||
|
self.db_sched_duration_sec,
|
||||||
|
self.evt_db_fetch_count,)
|
||||||
|
|
||||||
def __iadd__(self, other):
|
def __iadd__(self, other):
|
||||||
"""Add another ContextResourceUsage's stats to this one's.
|
"""Add another ContextResourceUsage's stats to this one's.
|
||||||
|
|
||||||
|
@ -104,12 +104,19 @@ class Measure(object):
|
|||||||
logger.warn("Expected context. (%r)", self.name)
|
logger.warn("Expected context. (%r)", self.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
usage = context.get_resource_usage() - self.start_usage
|
current = context.get_resource_usage()
|
||||||
block_ru_utime.labels(self.name).inc(usage.ru_utime)
|
usage = current - self.start_usage
|
||||||
block_ru_stime.labels(self.name).inc(usage.ru_stime)
|
try:
|
||||||
block_db_txn_count.labels(self.name).inc(usage.db_txn_count)
|
block_ru_utime.labels(self.name).inc(usage.ru_utime)
|
||||||
block_db_txn_duration.labels(self.name).inc(usage.db_txn_duration_sec)
|
block_ru_stime.labels(self.name).inc(usage.ru_stime)
|
||||||
block_db_sched_duration.labels(self.name).inc(usage.db_sched_duration_sec)
|
block_db_txn_count.labels(self.name).inc(usage.db_txn_count)
|
||||||
|
block_db_txn_duration.labels(self.name).inc(usage.db_txn_duration_sec)
|
||||||
|
block_db_sched_duration.labels(self.name).inc(usage.db_sched_duration_sec)
|
||||||
|
except ValueError:
|
||||||
|
logger.warn(
|
||||||
|
"Failed to save metrics! OLD: %r, NEW: %r",
|
||||||
|
self.start_usage, current
|
||||||
|
)
|
||||||
|
|
||||||
if self.created_context:
|
if self.created_context:
|
||||||
self.start_context.__exit__(exc_type, exc_val, exc_tb)
|
self.start_context.__exit__(exc_type, exc_val, exc_tb)
|
||||||
|
Loading…
Reference in New Issue
Block a user