github.com/thanos-io/thanos@v0.32.5/internal/cortex/util/labels.go (about) 1 // Copyright (c) The Cortex Authors. 2 // Licensed under the Apache License 2.0. 3 4 package util 5 6 import ( 7 "github.com/prometheus/common/model" 8 "github.com/prometheus/prometheus/model/labels" 9 ) 10 11 // LabelsToMetric converts a Labels to Metric 12 // Don't do this on any performance sensitive paths. 13 func LabelsToMetric(ls labels.Labels) model.Metric { 14 m := make(model.Metric, len(ls)) 15 for _, l := range ls { 16 m[model.LabelName(l.Name)] = model.LabelValue(l.Value) 17 } 18 return m 19 }