Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions metrics/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package metrics

import (
"context"
"slices"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -268,7 +269,7 @@ func (r *rootRegistry) Each(f MetricVisitor) {
sortedMetricIDs = append(sortedMetricIDs, name)
allMetrics[name] = metric
})
sortStrings(sortedMetricIDs)
slices.Sort(sortedMetricIDs)

for _, id := range sortedMetricIDs {
r.idToMetricMutex.RLock()
Expand Down Expand Up @@ -402,6 +403,21 @@ func toMetricTagsID(name string, tags Tags) metricTagsID {
// newSortedTags copies the tag slice before sorting so that in-place mutation does not affect the input slice.
func newSortedTags(tags Tags) Tags {
tagsCopy := append(tags[:0:0], tags...)
sortTags(tagsCopy)
slices.SortFunc(tagsCopy, compareTags)
return tagsCopy
}

func compareTags(a, b Tag) int {
switch {
case a.key < b.key:
return -1
case a.key > b.key:
return 1
case a.value < b.value:
return -1
case a.value > b.value:
return 1
default:
return 0
}
}
23 changes: 0 additions & 23 deletions metrics/sort.go

This file was deleted.

34 changes: 0 additions & 34 deletions metrics/sort_go121.go

This file was deleted.