go-kit / go-kit/kit

Edge case not handled in prometheus makeLabels function

Open
#633 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
27.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

The following function (https://github.com/go-kit/kit/blob/master/metrics/prometheus/prometheus.go#L161
) will have an index out of bounds error when labelValues is of odd length.

In the odd length case, one approach is to ignore the last unmatched value:
```
func makeLabels(labelValues ...string) prometheus.Labels {
labels := prometheus.Labels{}
for i := 0; i < len(labelValues) - 1; i += 2 {
labels[labelValues[i]] = labelValues[i+1]
}
return labels
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.