From 3c5b2bea94c5a764f9b7676f26ba40d5b71e2d34 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Sun, 11 Oct 2020 10:16:02 +0700 Subject: [PATCH] race_in_metrics (#1220) --- metrics/meter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metrics/meter.go b/metrics/meter.go index 60ae919d0..24c329b4b 100644 --- a/metrics/meter.go +++ b/metrics/meter.go @@ -207,7 +207,9 @@ func (m *StandardMeter) Count() int64 { // Mark records the occurrence of n events. func (m *StandardMeter) Mark(n int64) { - atomic.AddInt64(&m.snapshot.temp, n) + m.lock.Lock() + m.snapshot.temp = n + m.lock.Unlock() } // Rate1 returns the one-minute moving average rate of events per second.