add log for unexpected jitter (#2752)

This commit is contained in:
cnderrauber
2024-06-03 15:12:53 +08:00
committed by GitHub
parent b7ea733492
commit b90ade81da

View File

@@ -1,11 +1,13 @@
package sfu
import (
"fmt"
"sync"
"sync/atomic"
"time"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
)
@@ -46,9 +48,17 @@ func (s *ForwardStats) Update(arrival, left time.Time) {
func (s *ForwardStats) GetStats() (latency, jitter time.Duration) {
s.lock.Lock()
defer s.lock.Unlock()
w := s.latency.Summarize()
return time.Duration(w.Mean()), time.Duration(w.StdDev())
s.lock.Unlock()
latency, jitter = time.Duration(w.Mean()), time.Duration(w.StdDev())
// TODO: remove this check after debugging unexpected jitter issue
if jitter > 10*time.Second {
logger.Infow("unexpected forward jitter",
"jitter", jitter,
"stats", fmt.Sprintf("count %.2f, mean %.2f, stdDev %.2f", w.Count(), w.Mean(), w.StdDev()),
)
}
return
}
func (s *ForwardStats) GetLastStats(duration time.Duration) (latency, jitter time.Duration) {