Surface the % of players represented in metrics

This commit is contained in:
Gabe Kangas
2022-03-27 16:27:38 -07:00
parent 9f6151359f
commit 1e19e2a50e
5 changed files with 26 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"sort"
"github.com/owncast/owncast/core"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/utils"
@@ -34,6 +35,11 @@ func generateStreamHealthOverview() {
overview = errorCountOverview
}
// Determine what percentage of total players are represented in our overview.
totalPlayerCount := len(core.GetActiveViewers())
representation := utils.IntPercentage(len(windowedBandwidths), totalPlayerCount)
overview.Representation = representation
metrics.streamHealthOverview = overview
}
@@ -146,7 +152,7 @@ func errorCountHealthOverview() *models.StreamHealthOverview {
return nil
}
healthyPercentage := int(100 - ((float64(clientsWithErrors) / float64(totalNumberOfClients)) * 100))
healthyPercentage := 100 - utils.IntPercentage(clientsWithErrors, totalNumberOfClients)
return &models.StreamHealthOverview{
Healthy: healthyPercentage > healthyPercentageValue,

View File

@@ -4,6 +4,7 @@ import (
"math"
"time"
"github.com/owncast/owncast/core"
"github.com/owncast/owncast/utils"
)
@@ -326,3 +327,11 @@ func collectQualityVariantChanges() {
func GetQualityVariantChangesOverTime() []TimestampedValue {
return metrics.qualityVariantChanges
}
// GetPlaybackMetricsRepresentation returns what percentage of all known players
// the metrics represent.
func GetPlaybackMetricsRepresentation() int {
totalPlayerCount := len(core.GetActiveViewers())
representation := utils.IntPercentage(len(windowedBandwidths), totalPlayerCount)
return representation
}