Skip to content

Commit

Permalink
Fix missing metric name in k6 stats (MetricsJSONAPI)
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Mar 9, 2022
1 parent c31e840 commit a3d7fda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/v1/metric_jsonapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func (m MetricsJSONAPI) Metrics() []Metric {
list := make([]Metric, 0, len(m.Data))

for _, metric := range m.Data {
list = append(list, metric.Attributes)
m := metric.Attributes
m.Name = metric.ID
list = append(list, m)
}

return list
Expand Down
4 changes: 4 additions & 0 deletions api/v1/metric_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func TestGetMetrics(t *testing.T) {
assert.Equal(t, stats.Time, metric.Contains.Type)
assert.True(t, metric.Tainted.Valid)
assert.True(t, metric.Tainted.Bool)

resMetrics := envelop.Metrics()
assert.Len(t, resMetrics, 1)
assert.Equal(t, resMetrics[0].Name, "my_metric")
})
}

Expand Down

0 comments on commit a3d7fda

Please sign in to comment.