Merge "Improve metric error handling"

This commit is contained in:
Zuul 2018-11-20 13:15:22 +00:00 committed by Gerrit Code Review
commit 301d2871d0
2 changed files with 8 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class MetricsAggregator(object):
try:
metrics.extend(metric.flush())
except Exception:
log.exception('Error flushing {0} metrics.'.format(metric.name))
log.exception('Error flushing {0} metrics.'.format(metric.metric['name']))
# Log a warning regarding metrics with old timestamps being submitted
if self.num_discarded_old_points > 0:

View File

@ -53,6 +53,13 @@ class Metric(object):
def flush(self):
if self.timestamp is None:
return []
if self.value is None:
log.error('Value of None is not supported, will not send. '
'Metric %s with dimensions %s at time %d',
self.metric['name'],
self.metric['dimensions'],
self.timestamp)
return []
envelope = self.measurement(self.value, self.timestamp)
self.timestamp = None