diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c8dac8f..8477ba494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ will still be backwards compatible if only `url` is specified. ### Bugfixes - [#170](https://github.com/influxdb/telegraf/issues/170): Systemd support +- [#175](https://github.com/influxdb/telegraf/issues/175): Set write precision before gathering metrics ## v0.1.8 [2015-09-04] diff --git a/accumulator.go b/accumulator.go index b756cc16e..ea90b6620 100644 --- a/accumulator.go +++ b/accumulator.go @@ -25,7 +25,11 @@ type BatchPoints struct { } // Add adds a measurement -func (bp *BatchPoints) Add(measurement string, val interface{}, tags map[string]string) { +func (bp *BatchPoints) Add( + measurement string, + val interface{}, + tags map[string]string, +) { bp.mu.Lock() defer bp.mu.Unlock() diff --git a/agent.go b/agent.go index 1f40eb04b..12533d286 100644 --- a/agent.go +++ b/agent.go @@ -196,16 +196,17 @@ func (a *Agent) crankParallel() error { go func(plugin *runningPlugin) { defer wg.Done() - var acc BatchPoints - acc.Debug = a.Debug - acc.Prefix = plugin.name + "_" - acc.Config = plugin.config + var bp BatchPoints + bp.Debug = a.Debug + bp.Prefix = plugin.name + "_" + bp.Config = plugin.config + bp.Precision = a.Precision - if err := plugin.plugin.Gather(&acc); err != nil { + if err := plugin.plugin.Gather(&bp); err != nil { log.Printf("Error in plugin [%s]: %s", plugin.name, err) } - points <- &acc + points <- &bp }(plugin) } @@ -233,6 +234,7 @@ func (a *Agent) crank() error { var bp BatchPoints bp.Debug = a.Debug + bp.Precision = a.Precision for _, plugin := range a.plugins { bp.Prefix = plugin.name + "_" @@ -248,7 +250,6 @@ func (a *Agent) crank() error { if a.UTC { bp.Time = bp.Time.UTC() } - bp.Precision = a.Precision return a.flush(&bp) } @@ -266,6 +267,7 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err bp.Prefix = plugin.name + "_" bp.Config = plugin.config + bp.Precision = a.Precision if err := plugin.plugin.Gather(&bp); err != nil { log.Printf("Error in plugin [%s]: %s", plugin.name, err) @@ -277,7 +279,6 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err if a.UTC { bp.Time = bp.Time.UTC() } - bp.Precision = a.Precision if err := a.flush(&bp); err != nil { outerr = errors.New("Error encountered processing plugins & outputs")