count and log all discarded frames, decode errors, lost packets (#4363)
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_highlevel (push) Waiting to run

Discarded frames, decode errors and lost packets were logged
individually, then there was a mechanism that prevented more than 1 log
entry per second from being printed, resulting in inaccurate reports.

Now discarded frames, decode errors and lost packets are accurately
counted, and their count is printed once every second.
This commit is contained in:
Alessandro Ros 2025-03-25 21:59:58 +01:00 committed by GitHub
parent 65a2f63081
commit 986e270862
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 389 additions and 122 deletions

View file

@ -9,6 +9,7 @@ import (
srt "github.com/datarhei/gosrt"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/counterdumper"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/bluenviron/mediamtx/internal/protocols/mpegts"
@ -75,10 +76,24 @@ func (s *Source) runReader(sconn srt.Conn) error {
return err
}
decodeErrLogger := logger.NewLimitedLogger(s)
decodeErrors := &counterdumper.CounterDumper{
OnReport: func(val uint64) {
s.Log(logger.Warn, "%s decode %s",
val,
func() string {
if val == 1 {
return "error"
}
return "errors"
}())
},
}
r.OnDecodeError(func(err error) {
decodeErrLogger.Log(logger.Warn, err.Error())
decodeErrors.Start()
defer decodeErrors.Stop()
r.OnDecodeError(func(_ error) {
decodeErrors.Increase()
})
var stream *stream.Stream