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

Function MetricNameFromLabelAdapters

pkg/util/extract/extract.go:18–27  ·  view source on GitHub ↗

MetricNameFromLabelAdapters extracts the metric name from a list of LabelPairs. The returned metric name string is a copy of the label value.

(labels []cortexpb.LabelAdapter)

Source from the content-addressed store, hash-verified

16// MetricNameFromLabelAdapters extracts the metric name from a list of LabelPairs.
17// The returned metric name string is a copy of the label value.
18func MetricNameFromLabelAdapters(labels []cortexpb.LabelAdapter) (string, error) {
19 unsafeMetricName, err := UnsafeMetricNameFromLabelAdapters(labels)
20 if err != nil {
21 return "", err
22 }
23
24 // Force a string copy since LabelAdapter is often a pointer into
25 // a large gRPC buffer which we don't want to keep alive on the heap.
26 return string([]byte(unsafeMetricName)), nil
27}
28
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).

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected