2020-10-02 00:06:14 -07:00
|
|
|
package metrics
|
|
|
|
|
2022-03-06 19:43:57 -08:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nakabonne/tstorage"
|
|
|
|
)
|
2020-10-02 00:06:14 -07:00
|
|
|
|
|
|
|
type timestampedValue struct {
|
|
|
|
Time time.Time `json:"time"`
|
|
|
|
Value int `json:"value"`
|
|
|
|
}
|
2022-03-06 19:43:57 -08:00
|
|
|
|
|
|
|
func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []timestampedValue {
|
|
|
|
tv := []timestampedValue{}
|
|
|
|
for _, d := range dp {
|
|
|
|
tv = append(tv, timestampedValue{Time: time.Unix(d.Timestamp, 0), Value: int(d.Value)})
|
|
|
|
}
|
|
|
|
|
|
|
|
return tv
|
|
|
|
}
|