Skip to content

Commit

Permalink
Fix duplicate name in Prometheus labels
Browse files Browse the repository at this point in the history
  • Loading branch information
naviator committed Apr 9, 2022
1 parent 983a3bf commit 588efeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 6 additions & 12 deletions printer/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,12 @@ func (rp *ReportPrinter) printPrometheusMetricGauge(
}

func (rp *ReportPrinter) getCommonPrometheusLabels() ([]*promtypes.LabelPair, error) {
labels := make([]*promtypes.LabelPair, 0, len(rp.Report.Tags)+5)

labels = append(labels,
&promtypes.LabelPair{
Name: ptrString("name"),
Value: &rp.Report.Name,
},
&promtypes.LabelPair{
Name: ptrString("end_reason"),
Value: ptrString(string(rp.Report.EndReason)),
},
)
options := map[string]string{
"name": rp.Report.Name,
"end_reason": string(rp.Report.EndReason),
}

options := map[string]string{}
type Alias runner.Options
j, err := json.Marshal(&struct {
ImportPaths string `json:"import-paths"`
Expand Down Expand Up @@ -263,6 +255,8 @@ func (rp *ReportPrinter) getCommonPrometheusLabels() ([]*promtypes.LabelPair, er
delete(options, "load-max-duration")
}

labels := make([]*promtypes.LabelPair, 0, len(rp.Report.Tags)+5)

for k, v := range options {
k, v := k, v

Expand Down
1 change: 1 addition & 0 deletions printer/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestPrinter_printPrometheus(t *testing.T) {
"Internal": 3,
"DeadlineExceeded": 2},
Options: runner.Options{
Name: "run name",
Call: "helloworld.Greeter.SayHello",
Proto: "/apis/greeter.proto",
Host: "0.0.0.0:50051",
Expand Down

0 comments on commit 588efeb

Please sign in to comment.