MCPcopy Create free account
hub / github.com/cortexproject/cortex / FromMetricsToLabelAdapters

Function FromMetricsToLabelAdapters

pkg/cortexpb/compat.go:131–141  ·  view source on GitHub ↗

FromMetricsToLabelAdapters converts model.Metric to []LabelAdapter. Don't do this on any performance sensitive paths. The result is sorted.

(metric model.Metric)

Source from the content-addressed store, hash-verified

129// Don't do this on any performance sensitive paths.
130// The result is sorted.
131func FromMetricsToLabelAdapters(metric model.Metric) []LabelAdapter {
132 result := make([]LabelAdapter, 0, len(metric))
133 for k, v := range metric {
134 result = append(result, LabelAdapter{
135 Name: string(k),
136 Value: string(v),
137 })
138 }
139 sort.Sort(byLabel(result)) // The labels should be sorted upon initialisation.
140 return result
141}
142
143func FromExemplarsToExemplarProtos(es []exemplar.Exemplar) []Exemplar {
144 result := make([]Exemplar, 0, len(es))

Callers 3

TestValidateLabels_UTF8Function · 0.92
TestValidateMetricNameFunction · 0.92
TestValidateLabelsFunction · 0.92

Calls 1

byLabelTypeAlias · 0.85

Tested by 3

TestValidateLabels_UTF8Function · 0.74
TestValidateMetricNameFunction · 0.74
TestValidateLabelsFunction · 0.74