Skip to content

Commit

Permalink
batch error for decoder (template warnings)
Browse files Browse the repository at this point in the history
  • Loading branch information
lspgn committed Dec 9, 2023
1 parent 0fbc506 commit f16b6e0
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions cmd/goflow2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ func main() {
decodeFunc = metrics.PromDecoderWrapper(p.DecodeFlow, listenAddrUrl.Scheme)
pipes = append(pipes, p)

bm := utils.NewBatchMute(*ErrInt, *ErrCnt)

// starts receivers
// the function either returns an error
if err := recv.Start(hostname, int(port), decodeFunc); err != nil {
Expand All @@ -293,13 +295,25 @@ func main() {
case <-q:
return
case err := <-recv.Errors():
l := l.WithError(err)
if errors.Is(err, netflow.ErrorTemplateNotFound) {
l.Warn("template error")
} else if errors.Is(err, net.ErrClosed) {

if errors.Is(err, net.ErrClosed) {
l.Info("closed receiver")
} else {
continue
} else if !errors.Is(err, netflow.ErrorTemplateNotFound) {
l.Error("error")
continue
}

muted, skipped := bm.Increment()
if muted && skipped == 0 {
log.Warn("too many receiver messages, muting")
} else if !muted && skipped > 0 {
log.Warnf("skipped %d receiver messages", skipped)
} else if !muted {
l := l.WithError(err)
if errors.Is(err, netflow.ErrorTemplateNotFound) {
l.Warn("template error")
}
}

}
Expand Down

0 comments on commit f16b6e0

Please sign in to comment.