File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -404,7 +404,7 @@ func (ts *timespan) CompleteWithDuration(value time.Duration) {
404
404
}
405
405
406
406
type statStore struct {
407
- // todo: no idea how memory was managed here, when is are the entries ever gc'd ?
407
+ // todo: no idea how memory is managed here, when are the map entries ever deleted ?
408
408
counters sync.Map
409
409
gauges sync.Map
410
410
timers sync.Map
@@ -451,6 +451,8 @@ func (s *statStore) Flush() {
451
451
}
452
452
s .mu .RUnlock ()
453
453
454
+ // todo: if we're not deleting the data we flush from these maps, won't we just keep resending them?
455
+
454
456
s .counters .Range (func (key , v interface {}) bool {
455
457
// do not flush counters that are set to zero
456
458
if value := v .(* counter ).latch (); value != 0 {
@@ -470,7 +472,9 @@ func (s *statStore) Flush() {
470
472
for _ , value := range timer .CollectedValue () {
471
473
s .sink .FlushAggregatedTimer (key .(string ), value , sampleRate )
472
474
}
475
+ s .timers .Delete (key ) // delete it from the map so it's not flushed again
473
476
}
477
+
474
478
return true
475
479
})
476
480
@@ -593,7 +597,6 @@ func (s *statStore) newTimer(serializedName string, base time.Duration) timer {
593
597
}
594
598
}
595
599
596
- // todo: do we need special rules to not lose active reservoirs
597
600
if v , loaded := s .timers .LoadOrStore (serializedName , t ); loaded {
598
601
return v .(timer )
599
602
}
You can’t perform that action at this time.
0 commit comments