Skip to content
Closed
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/lyft/gostats

go 1.18
go 1.21

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is breaking in that it relies on importers to upgrade to 1.21. The alternative is to add a dependency on golang.org/x/exp/slices.

All OSS dependents on gostats are forks of envoyproxy/ratelimit, and envoyproxy itself is at go1.26: https://github.com/envoyproxy/ratelimit/

https://pkg.go.dev/github.com/lyft/gostats?tab=importedby


require github.com/kelseyhightower/envconfig v1.4.0
20 changes: 17 additions & 3 deletions internal/tags/tags.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tags

import (
"sort"
"slices"
"strings"
"unsafe"
)
Expand Down Expand Up @@ -131,7 +131,21 @@ func (t TagSet) Sort() {
t.cas(3, 5)
t.cas(3, 4)
default:
sort.Sort(t)
slices.SortFunc(t, compareTags)
}
}

// compareTags orders Tags by Key, for use with slices.SortFunc. Using the
// generic slices.SortFunc instead of sort.Sort avoids boxing the TagSet
// into a sort.Interface, which otherwise allocates on every call.
func compareTags(a, b Tag) int {
switch {
case a.Key < b.Key:
return -1
case a.Key > b.Key:
return 1
default:
return 0
}
}

Expand Down Expand Up @@ -435,7 +449,7 @@ func SerializeTags(name string, tags map[string]string) string {
n += len(k) + len(v)
pairs = append(pairs, NewTag(k, v))
}
sort.Sort(pairs)
pairs.Sort()

// CEV: this is same as strings.Builder, but works with go1.9 and earlier
b := make([]byte, 0, n)
Expand Down
Loading