From bd0889abce9bf739414118d16b7f64a13380a620 Mon Sep 17 00:00:00 2001 From: gordon chung Date: Tue, 18 Nov 2014 15:40:30 -0500 Subject: [PATCH] transform samples only when transformers exist the pipeline is oddly setup to loop through each sample and attempt to transform it even when there are no transformers. this is madness and should be stopped -- this patch does this. at best, this should improve performance because of needless looping, at worst, we get rid of misleading 'tranforming sample' logs. Change-Id: I80ba2b7775fda03670c7fa556ad5a779c6eefd27 --- ceilometer/pipeline.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ceilometer/pipeline.py b/ceilometer/pipeline.py index 651a44907..62a8f5aba 100644 --- a/ceilometer/pipeline.py +++ b/ceilometer/pipeline.py @@ -288,15 +288,18 @@ class Sink(object): """ transformed_samples = [] - for sample in samples: - LOG.debug(_( - "Pipeline %(pipeline)s: Transform sample " - "%(smp)s from %(trans)s transformer") % ({'pipeline': self, - 'smp': sample, - 'trans': start})) - sample = self._transform_sample(start, ctxt, sample) - if sample: - transformed_samples.append(sample) + if not self.transformers: + transformed_samples = samples + else: + for sample in samples: + LOG.debug(_( + "Pipeline %(pipeline)s: Transform sample " + "%(smp)s from %(trans)s transformer") % ({'pipeline': self, + 'smp': sample, + 'trans': start})) + sample = self._transform_sample(start, ctxt, sample) + if sample: + transformed_samples.append(sample) if transformed_samples: for p in self.publishers: