Avoid raising exceptions in metrics
Sentry will catch the errors if they happen, so that should be good enough, and woun't make things explode if we hit the error condition.pull/5499/head
parent
5097aee740
commit
dc94773e60
|
@ -374,20 +374,26 @@ class LoggingContext(object):
|
||||||
|
|
||||||
# sanity check
|
# sanity check
|
||||||
if utime_delta < 0:
|
if utime_delta < 0:
|
||||||
raise ValueError("utime went backwards! %f < %f" % (
|
logger.error(
|
||||||
current.ru_utime, self.usage_start.ru_utime,
|
"utime went backwards! %f < %f",
|
||||||
))
|
current.ru_utime,
|
||||||
|
self.usage_start.ru_utime,
|
||||||
|
)
|
||||||
|
utime_delta = 0
|
||||||
|
|
||||||
if stime_delta < 0:
|
if stime_delta < 0:
|
||||||
raise ValueError("stime went backwards! %f < %f" % (
|
logger.error(
|
||||||
current.ru_stime, self.usage_start.ru_stime,
|
"stime went backwards! %f < %f",
|
||||||
))
|
current.ru_stime,
|
||||||
|
self.usage_start.ru_stime,
|
||||||
|
)
|
||||||
|
stime_delta = 0
|
||||||
|
|
||||||
return utime_delta, stime_delta
|
return utime_delta, stime_delta
|
||||||
|
|
||||||
def add_database_transaction(self, duration_sec):
|
def add_database_transaction(self, duration_sec):
|
||||||
if duration_sec < 0:
|
if duration_sec < 0:
|
||||||
raise ValueError('DB txn time can only be non-negative')
|
raise ValueError("DB txn time can only be non-negative")
|
||||||
self._resource_usage.db_txn_count += 1
|
self._resource_usage.db_txn_count += 1
|
||||||
self._resource_usage.db_txn_duration_sec += duration_sec
|
self._resource_usage.db_txn_duration_sec += duration_sec
|
||||||
|
|
||||||
|
@ -399,7 +405,7 @@ class LoggingContext(object):
|
||||||
connection
|
connection
|
||||||
"""
|
"""
|
||||||
if sched_sec < 0:
|
if sched_sec < 0:
|
||||||
raise ValueError('DB scheduling time can only be non-negative')
|
raise ValueError("DB scheduling time can only be non-negative")
|
||||||
self._resource_usage.db_sched_duration_sec += sched_sec
|
self._resource_usage.db_sched_duration_sec += sched_sec
|
||||||
|
|
||||||
def record_event_fetch(self, event_count):
|
def record_event_fetch(self, event_count):
|
||||||
|
|
Loading…
Reference in New Issue