Merge "Modifies metername and resource_id"

This commit is contained in:
Jenkins 2017-08-16 14:28:59 +00:00 committed by Gerrit Code Review
commit e17da5ec73
2 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,7 @@ class Meter(object):
def meter_name(self, vl):
"""Return meter name."""
# pylint: disable=no-self-use
resources = [vl.plugin, vl.type]
resources = [vl.type, vl.type_instance]
return '.'.join([i for i in resources if i])
def hostname(self, vl):
@ -42,7 +42,7 @@ class Meter(object):
def resource_id(self, vl):
"""Get resource ID."""
resources = [self.hostname(vl), vl.plugin_instance, vl.type_instance]
resources = [self.hostname(vl), vl.plugin, vl.plugin_instance]
return '-'.join([i for i in resources if i])
def unit(self, vl):

View File

@ -57,7 +57,9 @@ class Writer(object):
# take the plugin (specialized or default) for parsing the data
plugin = self._meters.get(vl.plugin)
# prepare all data related to the sample
metername = plugin.meter_name(vl)
metername = "{}@{}".format(
plugin.resource_id(vl), plugin.meter_name(vl))
unit = plugin.unit(vl)
timestamp = datetime.datetime.utcfromtimestamp(vl.time).isoformat()