Add a warning message if metric not found

Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
This commit is contained in:
Xiaodong Ye 2024-11-20 08:48:47 +08:00
parent 087adf328c
commit 2f4dbae09c
1 changed files with 5 additions and 0 deletions

View File

@ -230,6 +230,11 @@ func (c *rdmaCollector) Update(ch chan<- prometheus.Metric) error {
if !c.metricsPattern.MatchString(name) {
return
}
entry := c.entry(name)
if entry == nil {
c.logger.Warn("rdma metric not found", "name", name)
return
}
ch <- prometheus.MustNewConstMetric(c.entry(name), prometheus.GaugeValue,
value, labelValues...)
}