in collector/receiver/prometheusreceiver/internal/metrics_adjuster.go [215:236]
func (jm *JobsMap) get(job, instance string) *timeseriesMap {
sig := job + ":" + instance
// a read locke is taken here as we will not need to modify jobsMap if the target timeseriesMap is available.
jm.RLock()
tsm, ok := jm.jobsMap[sig]
jm.RUnlock()
defer jm.maybeGC()
if ok {
return tsm
}
jm.Lock()
defer jm.Unlock()
// Now that we've got an exclusive lock, check once more to ensure an entry wasn't created in the interim
// and then create a new timeseriesMap if required.
tsm2, ok2 := jm.jobsMap[sig]
if ok2 {
return tsm2
}
tsm2 = newTimeseriesMap()
jm.jobsMap[sig] = tsm2
return tsm2
}