Skip to content

Commit

Permalink
performancecounter: fix panic with counter names having brackets
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Dec 27, 2024
1 parent d979357 commit b875021
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions internal/collector/performancecounter/performancecounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ type Collector struct {

objects []Object

metricNameReplacer *strings.Replacer

// meta
subCollectorScrapeDurationDesc *prometheus.Desc
subCollectorScrapeSuccessDesc *prometheus.Desc
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit b875021

Please sign in to comment.