Add a bit of sanity to the stream health messages
This commit is contained in:
parent
422ae35e67
commit
2a6bebfb2a
@ -13,6 +13,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
healthyPercentageValue = 75
|
healthyPercentageValue = 75
|
||||||
maxCPUUsage = 90
|
maxCPUUsage = 90
|
||||||
|
minClientCountForDetails = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetStreamHealthOverview will return the stream health overview.
|
// GetStreamHealthOverview will return the stream health overview.
|
||||||
@ -37,9 +38,10 @@ func generateStreamHealthOverview() {
|
|||||||
|
|
||||||
// Determine what percentage of total players are represented in our overview.
|
// Determine what percentage of total players are represented in our overview.
|
||||||
totalPlayerCount := len(core.GetActiveViewers())
|
totalPlayerCount := len(core.GetActiveViewers())
|
||||||
|
if totalPlayerCount > 0 && len(windowedBandwidths) > 0 {
|
||||||
representation := utils.IntPercentage(len(windowedBandwidths), totalPlayerCount)
|
representation := utils.IntPercentage(len(windowedBandwidths), totalPlayerCount)
|
||||||
overview.Representation = representation
|
overview.Representation = representation
|
||||||
|
}
|
||||||
metrics.streamHealthOverview = overview
|
metrics.streamHealthOverview = overview
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +154,15 @@ func errorCountHealthOverview() *models.StreamHealthOverview {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
healthyPercentage := 100 - utils.IntPercentage(clientsWithErrors, totalNumberOfClients)
|
// Only return these detailed values and messages if we feel we have enough
|
||||||
message := fmt.Sprintf("%d of %d clients (%d%%) are experiencing different, unspecified, playback issues.", clientsWithErrors, totalNumberOfClients, healthyPercentage)
|
// clients to be able to make a reasonable assessment. This is an arbitrary
|
||||||
|
// number but 1 out of 1 isn't helpful.
|
||||||
|
message := ""
|
||||||
|
healthyPercentage := 0
|
||||||
|
|
||||||
|
if totalNumberOfClients >= minClientCountForDetails {
|
||||||
|
healthyPercentage := utils.IntPercentage(clientsWithErrors, totalNumberOfClients)
|
||||||
|
message = fmt.Sprintf("%d of %d clients (%d%%) may be experiencing some issues.", clientsWithErrors, totalNumberOfClients, healthyPercentage)
|
||||||
|
|
||||||
isUsingPassthrough := false
|
isUsingPassthrough := false
|
||||||
outputVariants := data.GetStreamOutputVariants()
|
outputVariants := data.GetStreamOutputVariants()
|
||||||
@ -166,6 +175,8 @@ func errorCountHealthOverview() *models.StreamHealthOverview {
|
|||||||
if isUsingPassthrough {
|
if isUsingPassthrough {
|
||||||
message = fmt.Sprintf("%d of %d clients (%d%%) are experiencing errors. You're currently using a video passthrough output, often known for causing playback issues for people. It is suggested you turn it off.", clientsWithErrors, totalNumberOfClients, healthyPercentage)
|
message = fmt.Sprintf("%d of %d clients (%d%%) are experiencing errors. You're currently using a video passthrough output, often known for causing playback issues for people. It is suggested you turn it off.", clientsWithErrors, totalNumberOfClients, healthyPercentage)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &models.StreamHealthOverview{
|
return &models.StreamHealthOverview{
|
||||||
Healthy: healthyPercentage > healthyPercentageValue,
|
Healthy: healthyPercentage > healthyPercentageValue,
|
||||||
Message: message,
|
Message: message,
|
||||||
|
@ -30,3 +30,14 @@ func TestGetHashtagsFromText(t *testing.T) {
|
|||||||
t.Error("Incorrect hashtags fetched from text.")
|
t.Error("Incorrect hashtags fetched from text.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPercentageUtilsTest(t *testing.T) {
|
||||||
|
total := 42
|
||||||
|
number := 18
|
||||||
|
|
||||||
|
percent := IntPercentage(number, total)
|
||||||
|
|
||||||
|
if percent != 42 {
|
||||||
|
t.Error("Incorrect percentage calculation.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user