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 (
"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
}