in exporter/collector/internal/datapointstorage/datapointcache.go [185:240]
func (c *Cache) gc(shutdown <-chan struct{}, tickerCh <-chan time.Time) bool {
select {
case <-shutdown:
return false
case <-tickerCh:
// garbage collect the numberCache
c.numberLock.Lock()
for id, point := range c.numberCache {
// for points that have been used, mark them as unused
if point.used.Load() {
point.used.Store(false)
} else {
// for points that have not been used, delete points
delete(c.numberCache, id)
}
}
c.numberLock.Unlock()
// garbage collect the summaryCache
c.summaryLock.Lock()
for id, point := range c.summaryCache {
// for points that have been used, mark them as unused
if point.used.Load() {
point.used.Store(false)
} else {
// for points that have not been used, delete points
delete(c.summaryCache, id)
}
}
c.summaryLock.Unlock()
// garbage collect the histogramCache
c.histogramLock.Lock()
for id, point := range c.histogramCache {
// for points that have been used, mark them as unused
if point.used.Load() {
point.used.Store(false)
} else {
// for points that have not been used, delete points
delete(c.histogramCache, id)
}
}
c.histogramLock.Unlock()
// garbage collect the exponentialHistogramCache
c.exponentialHistogramLock.Lock()
for id, point := range c.exponentialHistogramCache {
// for points that have been used, mark them as unused
if point.used.Load() {
point.used.Store(false)
} else {
// for points that have not been used, delete points
delete(c.exponentialHistogramCache, id)
}
}
c.exponentialHistogramLock.Unlock()
}
return true
}