From 386d5a3ccf4b1c9710799fc4b414747e43275888 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Fri, 18 Mar 2016 10:51:14 -0600 Subject: [PATCH] Do not write metrics if there are 0 to write closes #884 --- CHANGELOG.md | 1 + internal/models/running_output.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2a4856f..93a8950e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bugfixes [#890](https://github.com/influxdata/telegraf/issues/890): Create TLS config even if only ssl_ca is provided. +[#884](https://github.com/influxdata/telegraf/issues/884): Do not call write method if there are 0 metrics to write. ## v0.11.1 [2016-03-17] diff --git a/internal/models/running_output.go b/internal/models/running_output.go index 33fa4e120..1e3d44a61 100644 --- a/internal/models/running_output.go +++ b/internal/models/running_output.go @@ -121,6 +121,9 @@ func (ro *RunningOutput) Write() error { } func (ro *RunningOutput) write(metrics []telegraf.Metric) error { + if len(metrics) == 0 { + return nil + } start := time.Now() err := ro.Output.Write(metrics) elapsed := time.Since(start)