Skip to content

Commit

Permalink
fix invalid metrics panic
Browse files Browse the repository at this point in the history
  • Loading branch information
jzwlqx committed Sep 28, 2023
1 parent 43f34c9 commit 40c0a43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/exporter/probe/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ func (b *BatchMetrics) Collect(metrics chan<- prometheus.Metric) {
log.Errorf("%s undeclared metrics %s", b.name, name)
return
}
metrics <- prometheus.MustNewConstMetric(info.desc, info.valueType, val, labels...)
m, err := prometheus.NewConstMetric(info.desc, info.valueType, val, labels...)
if err != nil {
log.Errorf("%s failed create metrics, err: %v", b.name, err)
return
}
metrics <- m
}

err := b.ProbeCollector(emit)
Expand Down

0 comments on commit 40c0a43

Please sign in to comment.