Skip to content

Commit

Permalink
Pass the time to addPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
corny committed Apr 18, 2017
1 parent 0df8f5d commit 237e011
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions database/influxdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func Connect(configuration interface{}) (database.Connection, error) {
return db, nil
}

func (conn *Connection) addPoint(name string, tags models.Tags, fields models.Fields, time time.Time) {
point, err := client.NewPoint(name, tags.Map(), fields, time)
func (conn *Connection) addPoint(name string, tags models.Tags, fields models.Fields, t ...time.Time) {
point, err := client.NewPoint(name, tags.Map(), fields, t...)
if err != nil {
panic(err)
}
Expand Down
9 changes: 4 additions & 5 deletions database/influxdb/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
// InsertGlobals implementation of database
func (conn *Connection) InsertGlobals(stats *runtime.GlobalStats, time time.Time) {
conn.addPoint(MeasurementGlobal, nil, GlobalStatsFields(stats), time)
conn.addCounterMap(CounterMeasurementModel, stats.Models)
conn.addCounterMap(CounterMeasurementFirmware, stats.Firmwares)
conn.addCounterMap(CounterMeasurementModel, stats.Models, time)
conn.addCounterMap(CounterMeasurementFirmware, stats.Firmwares, time)
}

// GlobalStatsFields returns fields for InfluxDB
Expand All @@ -29,16 +29,15 @@ func GlobalStatsFields(stats *runtime.GlobalStats) map[string]interface{} {
// Saves the values of a CounterMap in the database.
// The key are used as 'value' tag.
// The value is used as 'counter' field.
func (conn *Connection) addCounterMap(name string, m runtime.CounterMap) {
now := time.Now()
func (conn *Connection) addCounterMap(name string, m runtime.CounterMap, t time.Time) {
for key, count := range m {
conn.addPoint(
name,
models.Tags{
models.Tag{Key: []byte("value"), Value: []byte(key)},
},
models.Fields{"count": count},
now,
t,
)
}
}

0 comments on commit 237e011

Please sign in to comment.