2020-10-02 09:06:14 +02:00
|
|
|
package metrics
|
|
|
|
|
2022-03-07 04:43:57 +01:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nakabonne/tstorage"
|
|
|
|
)
|
2020-10-02 09:06:14 +02:00
|
|
|
|
2022-03-17 01:34:44 +01:00
|
|
|
// TimestampedValue is a value with a timestamp.
|
|
|
|
type TimestampedValue struct {
|
2020-10-02 09:06:14 +02:00
|
|
|
Time time.Time `json:"time"`
|
2022-03-17 01:34:44 +01:00
|
|
|
Value float64 `json:"value"`
|
2020-10-02 09:06:14 +02:00
|
|
|
}
|
2022-03-07 04:43:57 +01:00
|
|
|
|
2022-03-17 01:34:44 +01:00
|
|
|
func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []TimestampedValue {
|
|
|
|
tv := []TimestampedValue{}
|
2022-03-07 04:43:57 +01:00
|
|
|
for _, d := range dp {
|
2022-03-17 01:34:44 +01:00
|
|
|
tv = append(tv, TimestampedValue{Time: time.Unix(d.Timestamp, 0), Value: d.Value})
|
2022-03-07 04:43:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return tv
|
|
|
|
}
|