lib/promscrape: create a single swosFunc per scrape_config

This commit is contained in:
Aliaksandr Valialkin 2021-04-08 09:31:05 +03:00
parent 084ee9f598
commit 3b1f0cb3f6

View File

@ -130,7 +130,6 @@ type ScrapeConfig struct {
}
func (sc *ScrapeConfig) mustStart(baseDir string) {
for i := range sc.KubernetesSDConfigs {
swosFunc := func(metaLabels map[string]string) interface{} {
target := metaLabels["__address__"]
sw, err := sc.swc.getScrapeWork(target, nil, metaLabels)
@ -140,6 +139,7 @@ func (sc *ScrapeConfig) mustStart(baseDir string) {
}
return sw
}
for i := range sc.KubernetesSDConfigs {
sc.KubernetesSDConfigs[i].MustStart(baseDir, swosFunc)
}
}