memory: fix panics if metrics does not exists (#1960)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2025-04-04 23:21:26 +02:00
committed by GitHub
parent 88c929ac6f
commit ecc805f0fa
39 changed files with 565 additions and 364 deletions

View File

@@ -122,7 +122,7 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
c.miSession = miSession
errs := make([]error, 0, 5)
errs := make([]error, 0)
if slices.Contains(c.config.CollectorsEnabled, subCollectorCluster) {
if err := c.buildCluster(); err != nil {
@@ -227,7 +227,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
wg.Wait()
close(errCh)
errs := make([]error, 0, 5)
errs := make([]error, 0)
for err := range errCh {
errs = append(errs, err)