diff --git a/lib/promscrape/config_test.go b/lib/promscrape/config_test.go index 85a5433583..b52d02d23a 100644 --- a/lib/promscrape/config_test.go +++ b/lib/promscrape/config_test.go @@ -28,7 +28,7 @@ func TestInternStringConcurrent(t *testing.T) { resultCh <- testInternString(t) }() } - timer := time.NewTimer(5*time.Second) + timer := time.NewTimer(5 * time.Second) for i := 0; i < concurrency; i++ { select { case err := <-resultCh: diff --git a/lib/promscrape/discovery/kubernetes/api_watcher.go b/lib/promscrape/discovery/kubernetes/api_watcher.go index b142ec3991..fd01321506 100644 --- a/lib/promscrape/discovery/kubernetes/api_watcher.go +++ b/lib/promscrape/discovery/kubernetes/api_watcher.go @@ -135,7 +135,8 @@ func (aw *apiWatcher) removeScrapeWorks(uw *urlWatcher, key string) { } 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 { swo := swcFunc(labels) // The reflect check is needed because of https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1