From b352a4f99c3fa412332bc955def21b4755e3110a Mon Sep 17 00:00:00 2001 From: Matthew Kuzminski Date: Thu, 16 Jan 2025 18:29:57 -0500 Subject: [PATCH] add critical optimization todo --- stats.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stats.go b/stats.go index 6828c7d..977eb07 100644 --- a/stats.go +++ b/stats.go @@ -516,6 +516,8 @@ func (s *statStore) Flush() { s.timers.Range(func(key, v interface{}) bool { if timer, ok := v.(*reservoirTimer); ok { + // todo: this locking is uncessary, rewrite reservoirTimer to return all values and clear the counter and unlock right away, we can calculate sample rate here + // lock while flushing to: // 1. provide correct sample rate // 2. allow for exit despite continuous writes