mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Enforce a bucket limit of 100 to v2 metrics calls (#20761)
Enforce a bucket count limit on metrics for v2 calls. If people hit this limit, they should move to v3, as certain calls explode with high bucket count. Reviewers: This *should* only affect v2 calls, but the complexity is overwhelming.
This commit is contained in:
17
cmd/utils.go
17
cmd/utils.go
@@ -36,6 +36,7 @@ import (
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"runtime/trace"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -1176,3 +1177,19 @@ func filterStorageClass(ctx context.Context, s string) string {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
type ordered interface {
|
||||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | string
|
||||
}
|
||||
|
||||
// mapKeysSorted returns the map keys as a sorted slice.
|
||||
func mapKeysSorted[Map ~map[K]V, K ordered, V any](m Map) []K {
|
||||
res := make([]K, 0, len(m))
|
||||
for k := range m {
|
||||
res = append(res, k)
|
||||
}
|
||||
sort.Slice(res, func(i, j int) bool {
|
||||
return res[i] < res[j]
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user