From 6bf4846ae843e5e920ecce3792988efeb4d623ff Mon Sep 17 00:00:00 2001 From: yusing Date: Thu, 13 Feb 2025 17:23:00 +0800 Subject: [PATCH] poller: clear errors after logging --- internal/metrics/period/poller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/metrics/period/poller.go b/internal/metrics/period/poller.go index 4a290c5..cdfde53 100644 --- a/internal/metrics/period/poller.go +++ b/internal/metrics/period/poller.go @@ -94,6 +94,10 @@ func (p *Poller[T, AggregateT]) gatherErrs() (string, bool) { return strings.Join(errs, "\n"), true } +func (p *Poller[T, AggregateT]) clearErrs() { + p.errs = p.errs[:0] +} + func (p *Poller[T, AggregateT]) pollWithTimeout(ctx context.Context) { ctx, cancel := context.WithTimeout(ctx, p.interval()) defer cancel() @@ -129,6 +133,7 @@ func (p *Poller[T, AggregateT]) Start() { if ok { logging.Error().Msg(errs) } + p.clearErrs() } } }()