Improve frequency of stats update (#673)
* Improve frequency of stats update Prometheus stats are updated as the data becomes available, instead of aggregated along with telemetry batches. Node availability decisions can now react much faster to these stats. * use the same intervals for connection quality updates
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
connectionQualityUpdateInterval = 5 * time.Second
|
||||
UpdateInterval = 2 * time.Second
|
||||
)
|
||||
|
||||
type ConnectionStatsParams struct {
|
||||
@@ -47,7 +47,7 @@ func NewConnectionStats(params ConnectionStatsParams) *ConnectionStats {
|
||||
}
|
||||
|
||||
func (cs *ConnectionStats) Start() {
|
||||
go cs.updateStats()
|
||||
go cs.updateStatsWorker()
|
||||
}
|
||||
|
||||
func (cs *ConnectionStats) Close() {
|
||||
@@ -127,10 +127,10 @@ func (cs *ConnectionStats) getStat() *livekit.AnalyticsStat {
|
||||
}
|
||||
}
|
||||
|
||||
func (cs *ConnectionStats) updateStats() {
|
||||
func (cs *ConnectionStats) updateStatsWorker() {
|
||||
interval := cs.params.UpdateInterval
|
||||
if interval == 0 {
|
||||
interval = connectionQualityUpdateInterval
|
||||
interval = UpdateInterval
|
||||
}
|
||||
|
||||
tk := time.NewTicker(interval)
|
||||
|
||||
Reference in New Issue
Block a user