Improve metric error handling
flush() should not produce a metric if value is None (causes exception in monasca-api). Fix the exception message in flush() to use the correct data structure. Change-Id: I62d31270db9e70f16d2a38a73856009c52c098e6 Story: 2004276 Task: 27825
This commit is contained in:
parent
cb74366bbc
commit
f2e1f03fc8
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user