race_in_metrics (#1220)

This commit is contained in:
Alex Sharov 2020-10-11 10:16:02 +07:00 committed by GitHub
parent 8415ab475e
commit 3c5b2bea94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,7 +207,9 @@ func (m *StandardMeter) Count() int64 {
// Mark records the occurrence of n events. // Mark records the occurrence of n events.
func (m *StandardMeter) Mark(n int64) { 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. // Rate1 returns the one-minute moving average rate of events per second.