Skip to content

Commit a88d237

Browse files
committed
address comments
Signed-off-by: Ben Ye <[email protected]>
1 parent 5b6e1eb commit a88d237

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

pkg/util/validation/limits.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ func (o *Overrides) EnforceMetadataMetricName(userID string) bool {
725725
return o.GetOverridesForUser(userID).EnforceMetadataMetricName
726726
}
727727

728-
// MaxNativeHistogramBuckets.
728+
// MaxNativeHistogramBuckets returns the maximum total number of positive and negative buckets of a single native histogram
729+
// a user is allowed to store.
729730
func (o *Overrides) MaxNativeHistogramBuckets(userID string) int {
730731
return o.GetOverridesForUser(userID).MaxNativeHistogramBuckets
731732
}

pkg/util/validation/validate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const (
5353
exemplarTimestampInvalid = "exemplar_timestamp_invalid"
5454

5555
// Native Histogram specific validation reasons
56-
nativeHistogramBucketsExceeded = "native_histogram_buckets_exceeded"
56+
nativeHistogramBucketCountLimitExceeded = "native_histogram_buckets_exceeded"
5757

5858
// RateLimited is one of the values for the reason to discard samples.
5959
// Declared here to avoid duplication in ingester and distributor.
@@ -281,13 +281,13 @@ func ValidateNativeHistogram(validateMetrics *ValidateMetrics, limits *Limits, u
281281
}
282282
// Exceed limit.
283283
if histogram.Schema <= cortexpb.ExponentialSchemaMin {
284-
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketsExceeded, userID).Inc()
284+
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketCountLimitExceeded, userID).Inc()
285285
return cortexpb.Histogram{}, newHistogramBucketLimitExceededError(ls, limits.MaxNativeHistogramBuckets)
286286
}
287287
fh := cortexpb.FloatHistogramProtoToFloatHistogram(histogram)
288288
for len(fh.PositiveBuckets)+len(fh.NegativeBuckets) > limits.MaxNativeHistogramBuckets {
289289
if fh.Schema <= cortexpb.ExponentialSchemaMin {
290-
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketsExceeded, userID).Inc()
290+
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketCountLimitExceeded, userID).Inc()
291291
return cortexpb.Histogram{}, newHistogramBucketLimitExceededError(ls, limits.MaxNativeHistogramBuckets)
292292
}
293293
fh = fh.ReduceResolution(fh.Schema - 1)
@@ -303,13 +303,13 @@ func ValidateNativeHistogram(validateMetrics *ValidateMetrics, limits *Limits, u
303303
}
304304
// Exceed limit.
305305
if histogram.Schema <= cortexpb.ExponentialSchemaMin {
306-
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketsExceeded, userID).Inc()
306+
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketCountLimitExceeded, userID).Inc()
307307
return cortexpb.Histogram{}, newHistogramBucketLimitExceededError(ls, limits.MaxNativeHistogramBuckets)
308308
}
309309
h := cortexpb.HistogramProtoToHistogram(histogram)
310310
for len(h.PositiveBuckets)+len(h.NegativeBuckets) > limits.MaxNativeHistogramBuckets {
311311
if h.Schema <= cortexpb.ExponentialSchemaMin {
312-
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketsExceeded, userID).Inc()
312+
validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketCountLimitExceeded, userID).Inc()
313313
return cortexpb.Histogram{}, newHistogramBucketLimitExceededError(ls, limits.MaxNativeHistogramBuckets)
314314
}
315315
h = h.ReduceResolution(h.Schema - 1)

pkg/util/validation/validate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func TestValidateNativeHistogram(t *testing.T) {
392392
actualHistogram, actualErr := ValidateNativeHistogram(validateMetrics, limits, userID, lbls, tc.histogram)
393393
if tc.expectedErr != nil {
394394
require.Equal(t, tc.expectedErr, actualErr)
395-
require.Equal(t, float64(1), testutil.ToFloat64(validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketsExceeded, userID)))
395+
require.Equal(t, float64(1), testutil.ToFloat64(validateMetrics.DiscardedSamples.WithLabelValues(nativeHistogramBucketCountLimitExceeded, userID)))
396396
} else {
397397
require.NoError(t, actualErr)
398398
require.Equal(t, tc.expectedHistogram, actualHistogram)

0 commit comments

Comments
 (0)