lib/promscrape/discovery/kubernetes: pre-populate labelsByKey in reloadObject()

This commit is contained in:
Aliaksandr Valialkin 2021-02-28 15:09:28 +02:00
parent d9c7c71abc
commit 82441537ff

View file

@ -305,8 +305,13 @@ func (uw *urlWatcher) reloadObjects() string {
logger.Errorf("cannot parse response from %q: %s", requestURL, err)
return ""
}
labelsByKey := make(map[string][]map[string]string, len(objectsByKey))
for k, o := range objectsByKey {
labelsByKey[k] = o.getTargetLabels(uw)
}
uw.mu.Lock()
uw.objectsByKey = objectsByKey
uw.labelsByKey = labelsByKey
uw.mu.Unlock()
return metadata.ResourceVersion
}