experimental race free labels
Some checks failed
codeql / analyze (go) (push) Failing after 44s
build / test (push) Failing after 4m52s
build / lint (push) Successful in 9m27s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-11-07 16:49:16 +03:00
parent dd71d9ec59
commit 6f6d362c20

View File

@ -328,11 +328,13 @@ func (m *prometheusMeter) Set(opts ...meter.Option) meter.Meter {
}
func labelMetric(labels []string) []*dto.LabelPair {
dtoLabels := make([]*dto.LabelPair, 0, len(labels)/2)
for idx := 0; idx < len(labels); idx += 2 {
nl := make([]string, len(labels))
copy(nl, labels)
dtoLabels := make([]*dto.LabelPair, 0, len(nl)/2)
for idx := 0; idx < len(nl); idx += 2 {
dtoLabels = append(dtoLabels, &dto.LabelPair{
Name: &(labels[idx]),
Value: &(labels[idx+1]),
Name: &(nl[idx]),
Value: &(nl[idx+1]),
})
}
return dtoLabels