self.name doesn't exist in Rate and Counter object

Saw error message in collector log showing:
AttributeError: 'Rate' object has no attribute 'name'

In the new base metric class init function, variable name
got passed into self.metric. That's why self.name doesn't
exist anymore.

Change-Id: Idfd2fe5d257332327449e2766544dd36d8a003c1
This commit is contained in:
Kaiyan Sheng 2016-08-02 09:52:55 -06:00
parent feb0a83bd9
commit 9dc0e21205
2 changed files with 8 additions and 8 deletions

View File

@ -3,9 +3,6 @@
"""
import logging
from monasca_agent.common.exceptions import UnknownValue
log = logging.getLogger(__name__)
@ -78,7 +75,7 @@ class Counter(Metric):
self.timestamp = timestamp
except TypeError:
log.error("metric {} value {} sample_rate {}".
format(self.name, value, sample_rate))
format(self.metric['name'], value, sample_rate))
def flush(self):
envelope = self.measurement(self.value, self.timestamp)
@ -116,14 +113,15 @@ class Rate(Metric):
if delta_v < 0:
log.debug('Metric {0} has a rate < 0. New value = {1} and old '
'value = {2}. Counter may have been Reset.'.
format(self.name, sample2[1], sample1[1]))
format(self.metric['name'], sample2[1], sample1[1]))
return rate
try:
rate = delta_v / float(delta_t)
except ZeroDivisionError as e:
log.exception('Error in sampling metric {0}, time difference '
'between current time and last_update time is '
'0, returned {1}'.format(self.name, e))
'0, returned {1}'.
format(self.self.metric['name'], e))
return rate
def flush(self):

View File

@ -1,7 +1,9 @@
requests>=2.7.0,<=2.10.0
oslo.config<=3.12.0
oslo.utils<=3.15.0
oslo.concurrency<=3.13.0
oslo.config<=3.14.0
oslo.i18n<=3.8.0
oslo.utils<=3.16.0
oslo.vmware>=1.16.0,<=2.10.0
PyYAML>=3.1.0,<=3.11