Skip to content

Commit

Permalink
compute sample as dictionary once
Browse files Browse the repository at this point in the history
we shouldn't be wasting time doing the same thing over and over
in loop

Change-Id: Iaa5aeb5b91004945a24fab105c8b4884918c1644
  • Loading branch information
chungg committed Jan 8, 2018
1 parent 02e8ac2 commit 40317d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ceilometer/publisher/gnocchi.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ def event_match(self, event_type):

def sample_attributes(self, sample):
attrs = {}
sample_dict = sample.as_dict()
for name, definition in self._attributes.items():
value = definition.parse(sample.as_dict())
value = definition.parse(sample_dict)
if value is not None:
attrs[name] = value
return attrs
Expand Down

0 comments on commit 40317d7

Please sign in to comment.