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

Function getLabelValues

pkg/util/metrics_helper.go:368–394  ·  view source on GitHub ↗
(m *dto.Metric, labelNames []string)

Source from the content-addressed store, hash-verified

366}
367
368func getLabelValues(m *dto.Metric, labelNames []string) ([]string, bool) {
369 result := make([]string, 0, len(labelNames))
370
371 for _, ln := range labelNames {
372 found := false
373
374 // Look for the label among the metric ones. We re-iterate on each metric label
375 // which is algorithmically bad, but the main assumption is that the labelNames
376 // in input are typically very few units.
377 for _, lp := range m.GetLabel() {
378 if ln != lp.GetName() {
379 continue
380 }
381
382 result = append(result, lp.GetValue())
383 found = true
384 break
385 }
386
387 if !found {
388 // required labels not found
389 return nil, false
390 }
391 }
392
393 return result, true
394}
395
396func getLabelsString(labelValues []string) string {
397 // Get a buffer from the pool, reset it and release it at the

Callers 1

getMetricsWithLabelNamesFunction · 0.85

Calls 2

GetNameMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected