timestampedValue.go 459 B

12345678910111213141516171819202122
  1. package metrics
  2. import (
  3. "time"
  4. "github.com/nakabonne/tstorage"
  5. )
  6. // TimestampedValue is a value with a timestamp.
  7. type TimestampedValue struct {
  8. Time time.Time `json:"time"`
  9. Value float64 `json:"value"`
  10. }
  11. func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []TimestampedValue {
  12. tv := []TimestampedValue{}
  13. for _, d := range dp {
  14. tv = append(tv, TimestampedValue{Time: time.Unix(d.Timestamp, 0), Value: d.Value})
  15. }
  16. return tv
  17. }