From 8bb0bb0b3c4cb6ab774bf154715786a59b4449c1 Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Mon, 22 Jul 2024 10:56:17 +0200 Subject: [PATCH] fix_: fix ticker in metrics Create ticker in Start() instead of one global in service Fix #5548 --- centralizedmetrics/metrics.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/centralizedmetrics/metrics.go b/centralizedmetrics/metrics.go index 31a65bb34..441bea83e 100644 --- a/centralizedmetrics/metrics.go +++ b/centralizedmetrics/metrics.go @@ -33,6 +33,7 @@ type MetricService struct { done chan bool started bool wg sync.WaitGroup + interval time.Duration } func NewDefaultMetricService(db *sql.DB) *MetricService { @@ -45,7 +46,7 @@ func NewMetricService(repository MetricRepository, processor common.MetricProces return &MetricService{ repository: repository, processor: processor, - ticker: time.NewTicker(interval), + interval: interval, done: make(chan bool), } } @@ -54,6 +55,7 @@ func (s *MetricService) Start() { if s.started { return } + s.ticker = time.NewTicker(s.interval) s.wg.Add(1) s.started = true go func() {