From 699af30017930df9d6d7f215ab5f239de668294d Mon Sep 17 00:00:00 2001 From: Xiaodong Ye Date: Wed, 20 Nov 2024 08:48:47 +0800 Subject: [PATCH] Add a warning message if metric not found Signed-off-by: Xiaodong Ye --- collector/rdma_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/collector/rdma_linux.go b/collector/rdma_linux.go index f7563ae3..76eee2d1 100644 --- a/collector/rdma_linux.go +++ b/collector/rdma_linux.go @@ -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...) }