From 1001de7311d526f0b4ef79721003dc787c55b6ed Mon Sep 17 00:00:00 2001 From: tidwall Date: Sat, 24 Sep 2022 14:01:36 -0700 Subject: [PATCH] Refactor for better coverage --- internal/server/metrics.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/server/metrics.go b/internal/server/metrics.go index a5cd4623..78133ceb 100644 --- a/internal/server/metrics.go +++ b/internal/server/metrics.go @@ -92,9 +92,14 @@ func (s *Server) Collect(ch chan<- prometheus.Metric) { s.extStats(m) for metric, descr := range metricDescriptions { - if val, ok := m[metric].(int); ok { - ch <- prometheus.MustNewConstMetric(descr, prometheus.GaugeValue, float64(val)) - } else if val, ok := m[metric].(float64); ok { + val, ok := m[metric].(float64) + if !ok { + val2, ok2 := m[metric].(int) + if ok2 { + val, ok = float64(val2), true + } + } + if ok { ch <- prometheus.MustNewConstMetric(descr, prometheus.GaugeValue, val) } }