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