Skip to content

Commit

Permalink
test: fix grouped labels in the fake prometheus (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiankaminski-form3 authored Nov 9, 2023
1 parent 8ee2967 commit 937eb76
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/run/prom_push_gw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ func (f *FakePrometheus) ServeHTTP(response http.ResponseWriter, request *http.R
metricFamily := &io_prometheus_client.MetricFamily{}
expfmt.NewDecoder(request.Body, expfmt.ResponseFormat(request.Header)).Decode(metricFamily)
mf, ok := f.metricFamilies.Load(*metricFamily.Name)
if !ok {
if metricFamily.Metric != nil {
groupedLabels := parseGroupedLabels()
for _, m := range metricFamily.Metric {
m.Label = append(m.Label, groupedLabels...)
}

if metricFamily.Metric != nil {
groupedLabels := parseGroupedLabels()
for _, m := range metricFamily.Metric {
m.Label = append(m.Label, groupedLabels...)
}
}

if !ok {
f.metricFamilies.Store(*metricFamily.Name, metricFamily)
} else {
value, ok := mf.(*io_prometheus_client.MetricFamily)
Expand Down

0 comments on commit 937eb76

Please sign in to comment.