From 4bd67824ae039bb1c7cfa06de2e9636ef9079d3e Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Mon, 22 Jan 2018 11:16:07 -0800 Subject: [PATCH] Avoid loop creation in second processor pass (#3656) (cherry picked from commit 5270aa451c3da6e778bd831e0cd6903cfcfb305c) --- agent/agent.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index 8739f941d..b1250cc9f 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -308,7 +308,13 @@ func (a *Agent) flusher(shutdown chan struct{}, metricC chan telegraf.Metric, ag metrics = processor.Apply(metrics...) } for _, m := range metrics { - outMetricC <- m + for i, o := range a.Config.Outputs { + if i == len(a.Config.Outputs)-1 { + o.AddMetric(m) + } else { + o.AddMetric(m.Copy()) + } + } } } }