From b8750213fd3b13b99f05637a255b6e22999f7470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Fri, 27 Dec 2024 22:06:10 +0100 Subject: [PATCH] performancecounter: fix panic with counter names having brackets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- internal/collector/performancecounter/performancecounter.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/collector/performancecounter/performancecounter.go b/internal/collector/performancecounter/performancecounter.go index 3f5b4bdae..b4f5697be 100644 --- a/internal/collector/performancecounter/performancecounter.go +++ b/internal/collector/performancecounter/performancecounter.go @@ -54,8 +54,6 @@ type Collector struct { objects []Object - metricNameReplacer *strings.Replacer - // meta subCollectorScrapeDurationDesc *prometheus.Desc subCollectorScrapeSuccessDesc *prometheus.Desc @@ -166,7 +164,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { counters = append(counters, counter.Name) - field, err := func(name string) (field reflect.StructField, err error) { + field, err := func(name string) (_ reflect.StructField, err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("failed to create field for %s: %v", name, r) @@ -179,7 +177,6 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { Tag: reflect.StructTag(fmt.Sprintf(`perfdata:"%s"`, name)), }, nil }(counter.Name) - if err != nil { errs = append(errs, err)