fix: API label casing and count value for +Inf bucket v2 metrics (#20656)

This commit is contained in:
John Morales
2024-11-18 14:17:52 -05:00
committed by GitHub
parent e8a476ef5a
commit 485d833cd7
2 changed files with 139 additions and 4 deletions
+6 -2
View File
@@ -1875,13 +1875,17 @@ func getHistogramMetrics(hist *prometheus.HistogramVec, desc MetricDescription,
// add metrics with +Inf label
labels1 := make(map[string]string)
for _, lp := range dtoMetric.GetLabel() {
labels1[*lp.Name] = *lp.Value
if *lp.Name == "api" && toLowerAPILabels {
labels1[*lp.Name] = strings.ToLower(*lp.Value)
} else {
labels1[*lp.Name] = *lp.Value
}
}
labels1["le"] = fmt.Sprintf("%.3f", math.Inf(+1))
metrics = append(metrics, MetricV2{
Description: desc,
VariableLabels: labels1,
Value: dtoMetric.Counter.GetValue(),
Value: float64(dtoMetric.Histogram.GetSampleCount()),
})
}
return metrics