Move capacity check for stackdriver output plugin (#5479)

This commit is contained in:
Robert Edström 2019-02-27 02:40:21 +01:00 committed by Daniel Nelson
parent 85617887c4
commit a3f83afe4a
1 changed files with 1 additions and 5 deletions

View File

@ -199,7 +199,7 @@ func (s *Stackdriver) Write(metrics []telegraf.Metric) error {
for len(buckets) != 0 { for len(buckets) != 0 {
// can send up to 200 time series to stackdriver // can send up to 200 time series to stackdriver
timeSeries := make([]*monitoringpb.TimeSeries, 0, 200) 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] k := keys[i]
s := buckets[k] s := buckets[k]
timeSeries = append(timeSeries, s[0]) timeSeries = append(timeSeries, s[0])
@ -212,10 +212,6 @@ func (s *Stackdriver) Write(metrics []telegraf.Metric) error {
s = s[1:] s = s[1:]
buckets[k] = s buckets[k] = s
if len(timeSeries) == cap(timeSeries) {
break
}
} }
// Prepare time series request. // Prepare time series request.