owncast/metrics/timestampedValue.go
Gabe Kangas babbcecc9c
Stream performance metrics (#1785)
* WIP playback metrics

* Playback metrics collecting + APIs. Closes #793

* Cleanup console messages

* Update test

* Increase browser test timeout

* Update browser tests to not fail
2022-03-16 17:34:44 -07:00

22 lines
459 B
Go

package metrics
import (
"time"
"github.com/nakabonne/tstorage"
)
// TimestampedValue is a value with a timestamp.
type TimestampedValue struct {
Time time.Time `json:"time"`
Value float64 `json:"value"`
}
func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []TimestampedValue {
tv := []TimestampedValue{}
for _, d := range dp {
tv = append(tv, TimestampedValue{Time: time.Unix(d.Timestamp, 0), Value: d.Value})
}
return tv
}