Pass the time to addPoint
This commit is contained in:
parent
0df8f5d615
commit
237e011068
|
@ -78,8 +78,8 @@ func Connect(configuration interface{}) (database.Connection, error) {
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *Connection) addPoint(name string, tags models.Tags, fields models.Fields, time time.Time) {
|
func (conn *Connection) addPoint(name string, tags models.Tags, fields models.Fields, t ...time.Time) {
|
||||||
point, err := client.NewPoint(name, tags.Map(), fields, time)
|
point, err := client.NewPoint(name, tags.Map(), fields, t...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
// InsertGlobals implementation of database
|
// InsertGlobals implementation of database
|
||||||
func (conn *Connection) InsertGlobals(stats *runtime.GlobalStats, time time.Time) {
|
func (conn *Connection) InsertGlobals(stats *runtime.GlobalStats, time time.Time) {
|
||||||
conn.addPoint(MeasurementGlobal, nil, GlobalStatsFields(stats), time)
|
conn.addPoint(MeasurementGlobal, nil, GlobalStatsFields(stats), time)
|
||||||
conn.addCounterMap(CounterMeasurementModel, stats.Models)
|
conn.addCounterMap(CounterMeasurementModel, stats.Models, time)
|
||||||
conn.addCounterMap(CounterMeasurementFirmware, stats.Firmwares)
|
conn.addCounterMap(CounterMeasurementFirmware, stats.Firmwares, time)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalStatsFields returns fields for InfluxDB
|
// GlobalStatsFields returns fields for InfluxDB
|
||||||
|
@ -29,8 +29,7 @@ func GlobalStatsFields(stats *runtime.GlobalStats) map[string]interface{} {
|
||||||
// Saves the values of a CounterMap in the database.
|
// Saves the values of a CounterMap in the database.
|
||||||
// The key are used as 'value' tag.
|
// The key are used as 'value' tag.
|
||||||
// The value is used as 'counter' field.
|
// The value is used as 'counter' field.
|
||||||
func (conn *Connection) addCounterMap(name string, m runtime.CounterMap) {
|
func (conn *Connection) addCounterMap(name string, m runtime.CounterMap, t time.Time) {
|
||||||
now := time.Now()
|
|
||||||
for key, count := range m {
|
for key, count := range m {
|
||||||
conn.addPoint(
|
conn.addPoint(
|
||||||
name,
|
name,
|
||||||
|
@ -38,7 +37,7 @@ func (conn *Connection) addCounterMap(name string, m runtime.CounterMap) {
|
||||||
models.Tag{Key: []byte("value"), Value: []byte(key)},
|
models.Tag{Key: []byte("value"), Value: []byte(key)},
|
||||||
},
|
},
|
||||||
models.Fields{"count": count},
|
models.Fields{"count": count},
|
||||||
now,
|
t,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue