FromMetricsToLabelAdapters converts model.Metric to []LabelAdapter. Don't do this on any performance sensitive paths. The result is sorted.
(metric model.Metric)
| 129 | // Don't do this on any performance sensitive paths. |
| 130 | // The result is sorted. |
| 131 | func 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 | |
| 143 | func FromExemplarsToExemplarProtos(es []exemplar.Exemplar) []Exemplar { |
| 144 | result := make([]Exemplar, 0, len(es)) |