Fix bug in setting the precision before gathering metrics

Closes #175
This commit is contained in:
Cameron Sparr 2015-09-09 21:27:58 -06:00
parent 3c7c8926fb
commit 81f4aa9a5d
3 changed files with 15 additions and 9 deletions

View File

@ -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]

View File

@ -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()

View File

@ -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")