Add stream health overview collection + apis

This commit is contained in:
Gabe Kangas
2022-03-24 23:06:47 -07:00
parent 729de44fce
commit 410b413b84
8 changed files with 210 additions and 56 deletions

View File

@ -11,6 +11,7 @@ import (
// How often we poll for updates.
const hardwareMetricsPollingInterval = 1 * time.Minute
const playbackMetricsPollingInterval = 3 * time.Minute
const (
// How often we poll for updates.
@ -41,13 +42,18 @@ type CollectedMetrics struct {
medianLatency []TimestampedValue `json:"-"`
qualityVariantChanges []TimestampedValue `json:"-"`
streamHealthOverview *models.StreamHealthOverview
}
// Metrics is the shared Metrics instance.
var metrics *CollectedMetrics
var _getStatus func() models.Status
// Start will begin the metrics collection and alerting.
func Start(getStatus func() models.Status) {
_getStatus = getStatus
host := data.GetServerURL()
if host == "" {
host = "unknown"
@ -62,9 +68,17 @@ func Start(getStatus func() models.Status) {
metrics = new(CollectedMetrics)
go startViewerCollectionMetrics()
for range time.Tick(hardwareMetricsPollingInterval) {
handlePolling()
}
go func() {
for range time.Tick(hardwareMetricsPollingInterval) {
handlePolling()
}
}()
go func() {
for range time.Tick(playbackMetricsPollingInterval) {
handlePlaybackPolling()
}
}()
}
func handlePolling() {
@ -76,12 +90,6 @@ func handlePolling() {
collectRAMUtilization()
collectDiskUtilization()
collectPlaybackErrorCount()
collectLatencyValues()
collectSegmentDownloadDuration()
collectLowestBandwidth()
collectQualityVariantChanges()
// Alerting
handleAlerting()
}