in collector/receiver/prometheusreceiver/internal/metrics_adjuster.go [185:204]
func (jm *JobsMap) gc() {
jm.Lock()
defer jm.Unlock()
// once the structure is locked, confirm that gc() is still necessary
if time.Since(jm.lastGC) > jm.gcInterval {
for sig, tsm := range jm.jobsMap {
tsm.RLock()
tsmNotMarked := !tsm.mark
// take a read lock here, no need to get a full lock as we have a lock on the JobsMap
tsm.RUnlock()
if tsmNotMarked {
delete(jm.jobsMap, sig)
} else {
// a full lock will be obtained in here, if required.
tsm.gc()
}
}
jm.lastGC = time.Now()
}
}