ValidateAggregationLabels ensures a given set of labels are valid aggregation labels.
(labels []string)
| 20 | |
| 21 | // ValidateAggregationLabels ensures a given set of labels are valid aggregation labels. |
| 22 | func ValidateAggregationLabels(labels []string) error { |
| 23 | acceptable := LabelAll |
| 24 | |
| 25 | seen := make(map[string]any, len(acceptable)) |
| 26 | for _, label := range acceptable { |
| 27 | seen[label] = nil |
| 28 | } |
| 29 | |
| 30 | for _, label := range labels { |
| 31 | if _, found := seen[label]; !found { |
| 32 | return xerrors.Errorf("%q is not a valid aggregation label; only one or more of %q are acceptable", |
| 33 | label, strings.Join(acceptable, ", ")) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return nil |
| 38 | } |