Prevent stats update if the deltas are empty (#619)

* Prevent stats update if the deltas are empty

* increase force interval

* static check

* Change max delay to 30 seconds
This commit is contained in:
Raja Subramanian
2022-04-18 22:51:34 +05:30
committed by GitHub
parent 2e9bccfeff
commit a19ca69f5f
3 changed files with 24 additions and 5 deletions
+13 -1
View File
@@ -10,7 +10,10 @@ import (
"github.com/livekit/protocol/utils"
)
const livekitNamespace string = "livekit"
const (
livekitNamespace string = "livekit"
forceUpdateInterval int64 = 15
)
var (
MessageCounter *prometheus.CounterVec
@@ -66,6 +69,15 @@ func GetUpdatedNodeStats(prev *livekit.NodeStats) (*livekit.NodeStats, error) {
packetsOutNow := packetsOut.Load()
nackTotalNow := nackTotal.Load()
if bytesInNow == prev.BytesIn &&
bytesOutNow == prev.BytesOut &&
packetsInNow == prev.PacketsIn &&
packetsOutNow == prev.PacketsOut &&
nackTotalNow == prev.NackTotal &&
elapsed < forceUpdateInterval {
return nil, nil
}
return &livekit.NodeStats{
StartedAt: prev.StartedAt,
UpdatedAt: updatedAt,