2015-04-06 16:32:10 +00:00
|
|
|
package tivan
|
|
|
|
|
2015-04-07 00:24:24 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/influxdb/influxdb/client"
|
|
|
|
)
|
2015-04-06 16:32:10 +00:00
|
|
|
|
|
|
|
type BatchPoints struct {
|
|
|
|
client.BatchPoints
|
2015-04-07 00:24:24 +00:00
|
|
|
|
|
|
|
Debug bool
|
2015-04-06 16:32:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (bp *BatchPoints) Add(name string, val interface{}, tags map[string]string) {
|
2015-04-07 00:24:24 +00:00
|
|
|
if bp.Debug {
|
|
|
|
var tg []string
|
|
|
|
|
|
|
|
for k, v := range tags {
|
|
|
|
tg = append(tg, fmt.Sprintf("%s=\"%s\"", k, v))
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(tg)
|
|
|
|
|
|
|
|
fmt.Printf("> [%s] %s=%v\n", strings.Join(tg, " "), name, val)
|
|
|
|
}
|
|
|
|
|
2015-04-06 16:32:10 +00:00
|
|
|
bp.Points = append(bp.Points, client.Point{
|
|
|
|
Name: name,
|
|
|
|
Tags: tags,
|
|
|
|
Fields: map[string]interface{}{
|
|
|
|
"value": val,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|