Limit in getBucketUsageMetrics

This commit is contained in:
Klaus Post 2024-12-17 18:00:04 +01:00
parent 986165794b
commit 2a50d857c8
No known key found for this signature in database
GPG Key ID: BAA2096BE0B8A075

View File

@ -1836,8 +1836,8 @@ func getGoMetrics() *MetricsGroupV2 {
// getHistogramMetrics fetches histogram metrics and returns it in a []Metric
// Note: Typically used in MetricGroup.RegisterRead
//
// The last parameter is added for compatibility - if true it lowercases the
// `api` label values.
// The toLowerAPILabels parameter is added for compatibility,
// if set, it lowercases the `api` label values.
func getHistogramMetrics(hist *prometheus.HistogramVec, desc MetricDescription, toLowerAPILabels, limitBuckets bool) []MetricV2 {
ch := make(chan prometheus.Metric)
go func() {
@ -3281,7 +3281,12 @@ func getBucketUsageMetrics(opts MetricsGroupOpts) *MetricsGroupV2 {
if !globalSiteReplicationSys.isEnabled() {
bucketReplStats = globalReplicationStats.Load().getAllLatest(dataUsageInfo.BucketsUsage)
}
for bucket, usage := range dataUsageInfo.BucketsUsage {
buckets := mapKeysSorted(dataUsageInfo.BucketsUsage)
if len(buckets) > v2MetricsMaxBuckets {
buckets = buckets[:v2MetricsMaxBuckets]
}
for _, bucket := range buckets {
usage := dataUsageInfo.BucketsUsage[bucket]
quota, _ := globalBucketQuotaSys.Get(ctx, bucket)
metrics = append(metrics, MetricV2{