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)
| 16 | // MetricNameFromLabelAdapters extracts the metric name from a list of LabelPairs. |
| 17 | // The returned metric name string is a copy of the label value. |
| 18 | func 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). |
nothing calls this directly
no test coverage detected