File tree 1 file changed +3
-10
lines changed
1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -356,19 +356,12 @@ func main() {
356
356
}
357
357
358
358
func parseMetricTypePrefixes (inputPrefixes []string ) (metricTypePrefixes []string ) {
359
- // only keep unique prefixes
360
- uniqueKeys := make (map [string ]bool )
361
- uniquePrefixes := []string {}
362
- for _ , prefix := range inputPrefixes {
363
- if _ , ok := uniqueKeys [prefix ]; ! ok {
364
- uniqueKeys [prefix ] = true
365
- uniquePrefixes = append (uniquePrefixes , prefix )
366
- }
367
- }
359
+ // drop duplicate prefixes
360
+ slices .Sort (inputPrefixes )
361
+ uniquePrefixes := slices .Compact (inputPrefixes )
368
362
369
363
// drop prefixes that start with another existing prefix to avoid error:
370
364
// "collected metric xxx was collected before with the same name and label values"
371
- slices .Sort (uniquePrefixes )
372
365
for i , prefix := range uniquePrefixes {
373
366
if i == 0 {
374
367
metricTypePrefixes = []string {prefix }
You can’t perform that action at this time.
0 commit comments