From 7f53e1c6fea5e9e27f532e1e84beab7ecf5f7bd5 Mon Sep 17 00:00:00 2001 From: Xiaodong Ye Date: Tue, 24 Dec 2024 10:15:40 +0800 Subject: [PATCH] Refine code Signed-off-by: Xiaodong Ye --- collector/rdma_linux.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/collector/rdma_linux.go b/collector/rdma_linux.go index d9790ebb04..d75ae455eb 100644 --- a/collector/rdma_linux.go +++ b/collector/rdma_linux.go @@ -276,7 +276,7 @@ func (c *rdmaCollector) Update(ch chan<- prometheus.Metric) error { updateFunc := func(key string, value float64, labelValues ...string) { metric, ok := lookupTable[key] if !ok { - c.logger.Debug("rdma metric not found in lookup table", "key", key) + c.logger.Warn("rdma metric not found in lookup table", "key", key) return } if !c.metricsPattern.MatchString(metric) { @@ -293,10 +293,7 @@ func (c *rdmaCollector) Update(ch chan<- prometheus.Metric) error { } for _, portstats := range stats.PortStats { - for _, stat := range portstats.HwStats { - updateFunc(stat.Name, float64(stat.Value), device, fmt.Sprintf("%d", portstats.Port), interfaces) - } - for _, stat := range portstats.Stats { + for _, stat := range append(portstats.HwStats, portstats.Stats...) { updateFunc(stat.Name, float64(stat.Value), device, fmt.Sprintf("%d", portstats.Port), interfaces) } }