From a3f83afe4a4d4da5980dd8fa839b9110ac0c51cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Edstr=C3=B6m?= <108799+Legogris@users.noreply.github.com> Date: Wed, 27 Feb 2019 02:40:21 +0100 Subject: [PATCH] Move capacity check for stackdriver output plugin (#5479) --- plugins/outputs/stackdriver/stackdriver.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/outputs/stackdriver/stackdriver.go b/plugins/outputs/stackdriver/stackdriver.go index d57675bc3..572cdb4c7 100644 --- a/plugins/outputs/stackdriver/stackdriver.go +++ b/plugins/outputs/stackdriver/stackdriver.go @@ -199,7 +199,7 @@ func (s *Stackdriver) Write(metrics []telegraf.Metric) error { for len(buckets) != 0 { // can send up to 200 time series to stackdriver timeSeries := make([]*monitoringpb.TimeSeries, 0, 200) - for i := 0; i < len(keys); i++ { + for i := 0; i < len(keys) && len(timeSeries) < cap(timeSeries); i++ { k := keys[i] s := buckets[k] timeSeries = append(timeSeries, s[0]) @@ -212,10 +212,6 @@ func (s *Stackdriver) Write(metrics []telegraf.Metric) error { s = s[1:] buckets[k] = s - - if len(timeSeries) == cap(timeSeries) { - break - } } // Prepare time series request.