mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
lib/promscrape/discovery/kubernetes: do not pre-allocate memory for ScrapeWork objects
There is high chance that ScrapeWork objects won't be generated because of relabeling
This commit is contained in:
parent
90db923662
commit
e9f08b1e6a
@ -28,7 +28,7 @@ func TestInternStringConcurrent(t *testing.T) {
|
|||||||
resultCh <- testInternString(t)
|
resultCh <- testInternString(t)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
timer := time.NewTimer(5*time.Second)
|
timer := time.NewTimer(5 * time.Second)
|
||||||
for i := 0; i < concurrency; i++ {
|
for i := 0; i < concurrency; i++ {
|
||||||
select {
|
select {
|
||||||
case err := <-resultCh:
|
case err := <-resultCh:
|
||||||
|
@ -135,7 +135,8 @@ func (aw *apiWatcher) removeScrapeWorks(uw *urlWatcher, key string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getScrapeWorkObjectsForLabels(swcFunc ScrapeWorkConstructorFunc, labelss []map[string]string) []interface{} {
|
func getScrapeWorkObjectsForLabels(swcFunc ScrapeWorkConstructorFunc, labelss []map[string]string) []interface{} {
|
||||||
swos := make([]interface{}, 0, len(labelss))
|
// Do not pre-allocate swos, since it is likely the swos will be empty because of relabeling
|
||||||
|
var swos []interface{}
|
||||||
for _, labels := range labelss {
|
for _, labels := range labelss {
|
||||||
swo := swcFunc(labels)
|
swo := swcFunc(labels)
|
||||||
// The reflect check is needed because of https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1
|
// The reflect check is needed because of https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1
|
||||||
|
Loading…
Reference in New Issue
Block a user