Do not write metrics if there are 0 to write

closes #884
This commit is contained in:
Cameron Sparr 2016-03-18 10:51:14 -06:00
parent 061b749041
commit 77dcbe95c0
2 changed files with 4 additions and 0 deletions

View File

@ -10,6 +10,7 @@
### Bugfixes ### Bugfixes
[#890](https://github.com/influxdata/telegraf/issues/890): Create TLS config even if only ssl_ca is provided. [#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] ## v0.11.1 [2016-03-17]

View File

@ -121,6 +121,9 @@ func (ro *RunningOutput) Write() error {
} }
func (ro *RunningOutput) write(metrics []telegraf.Metric) error { func (ro *RunningOutput) write(metrics []telegraf.Metric) error {
if len(metrics) == 0 {
return nil
}
start := time.Now() start := time.Now()
err := ro.Output.Write(metrics) err := ro.Output.Write(metrics)
elapsed := time.Since(start) elapsed := time.Since(start)