Refactoring gauges to support floats, unit tests

This commit is contained in:
Cameron Sparr
2015-10-06 13:33:35 -06:00
parent d84a258b0a
commit d40351286a
3 changed files with 161 additions and 132 deletions

View File

@@ -13,7 +13,7 @@ import (
// BatchPoints is used to send a batch of data in a single write from telegraf
// to influx
type BatchPoints struct {
mu sync.Mutex
sync.Mutex
client.BatchPoints
@@ -71,8 +71,8 @@ func (bp *BatchPoints) Add(
val interface{},
tags map[string]string,
) {
bp.mu.Lock()
defer bp.mu.Unlock()
bp.Lock()
defer bp.Unlock()
measurement = bp.Prefix + measurement
@@ -113,8 +113,8 @@ func (bp *BatchPoints) AddFieldsWithTime(
// TODO this function should add the fields with the timestamp, but that will
// need to wait for the InfluxDB point precision/unit to be fixed
bp.AddFields(measurement, fields, tags)
// bp.mu.Lock()
// defer bp.mu.Unlock()
// bp.Lock()
// defer bp.Unlock()
// measurement = bp.Prefix + measurement
@@ -158,8 +158,8 @@ func (bp *BatchPoints) AddFields(
fields map[string]interface{},
tags map[string]string,
) {
bp.mu.Lock()
defer bp.mu.Unlock()
bp.Lock()
defer bp.Unlock()
measurement = bp.Prefix + measurement