Skip to content

Commit

Permalink
cni-metrics-helper metrics: do type assertion before type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
dshehbaj committed Dec 12, 2024
1 parent 5bcc561 commit 8183388
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/cni-metrics-helper/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ func producePrometheusMetrics(t metricsTarget, families map[string]*dto.MetricFa
case dto.MetricType_GAUGE:
metrics, ok := prometheusCNIMetrics[family.GetName()]
if ok {
metrics.(prometheus.Gauge).Set(action.data.curSingleDataPoint)
if gauge, isGauge := metrics.(prometheus.Gauge); isGauge {
gauge.Set(action.data.curSingleDataPoint)
} else {
t.getLogger().Warnf("Metric %s is not a Gauge type, skipping", family.GetName())
}
}
}
}
Expand Down

0 comments on commit 8183388

Please sign in to comment.