fix the bug that gnocchi dispatcher can't process single sample

When we use UDP to publish samples to Ceilometer-collector, it
always come one by one. So we have to check whether the gnocchi
dispatcher receive a single sample or a list.

Change-Id: Idb19c8b94681b827fdfcef9c0bbbf3b85688b23c
Closes-Bug:#1523124
This commit is contained in:
Gangyi Luo 2015-12-05 08:03:35 -08:00
parent c3bacea44f
commit cb90fbabf7
1 changed files with 3 additions and 0 deletions

View File

@ -235,6 +235,9 @@ class GnocchiDispatcher(dispatcher.MeterDispatcherBase):
return rd
def record_metering_data(self, data):
# We may have receive only one counter on the wire
if not isinstance(data, list):
data = [data]
# NOTE(sileht): skip sample generated by gnocchi itself
data = [s for s in data if not self._is_gnocchi_activity(s)]