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

Function UnsafeMetricNameFromLabelAdapters

pkg/util/extract/extract.go:31–38  ·  view source on GitHub ↗

UnsafeMetricNameFromLabelAdapters extracts the metric name from a list of LabelPairs. The returned metric name string is a reference to the label value (no copy).

(labels []cortexpb.LabelAdapter)

Source from the content-addressed store, hash-verified

29// UnsafeMetricNameFromLabelAdapters extracts the metric name from a list of LabelPairs.
30// The returned metric name string is a reference to the label value (no copy).
31func UnsafeMetricNameFromLabelAdapters(labels []cortexpb.LabelAdapter) (string, error) {
32 for _, label := range labels {
33 if label.Name == model.MetricNameLabel {
34 return label.Value, nil
35 }
36 }
37 return "", errNoMetricNameLabel
38}
39
40// MetricNameFromMetric extract the metric name from a model.Metric
41func MetricNameFromMetric(m model.Metric) (model.LabelValue, error) {

Callers 4

tokenForLabelsMethod · 0.92
ValidateSampleTimestampFunction · 0.92
ValidateMetricNameFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected