@@ -387,12 +387,12 @@ func ValidateNativeHistogram(validateMetrics *ValidateMetrics, limits *Limits, u
387387
388388 var nCount , pCount uint64
389389 if histogramSample .IsFloatHistogram () {
390- if err , c := checkHistogramBuckets (histogramSample .GetNegativeCounts (), & nCount , false ); err != nil {
390+ if c , err := checkHistogramBuckets (histogramSample .GetNegativeCounts (), & nCount , false ); err != nil {
391391 validateMetrics .DiscardedSamples .WithLabelValues (nativeHistogramNegativeBucketCount , userID ).Inc ()
392392 return cortexpb.Histogram {}, newNativeHistogramNegativeBucketCountError (ls , c )
393393 }
394394
395- if err , c := checkHistogramBuckets (histogramSample .GetPositiveCounts (), & pCount , false ); err != nil {
395+ if c , err := checkHistogramBuckets (histogramSample .GetPositiveCounts (), & pCount , false ); err != nil {
396396 validateMetrics .DiscardedSamples .WithLabelValues (nativeHistogramNegativeBucketCount , userID ).Inc ()
397397 return cortexpb.Histogram {}, newNativeHistogramNegativeBucketCountError (ls , c )
398398 }
@@ -408,12 +408,12 @@ func ValidateNativeHistogram(validateMetrics *ValidateMetrics, limits *Limits, u
408408 return cortexpb.Histogram {}, newNativeHistogramNegativeCountError (ls , histogramSample .GetCountFloat ())
409409 }
410410 } else {
411- if err , c := checkHistogramBuckets (histogramSample .GetNegativeDeltas (), & nCount , true ); err != nil {
411+ if c , err := checkHistogramBuckets (histogramSample .GetNegativeDeltas (), & nCount , true ); err != nil {
412412 validateMetrics .DiscardedSamples .WithLabelValues (nativeHistogramNegativeBucketCount , userID ).Inc ()
413413 return cortexpb.Histogram {}, newNativeHistogramNegativeBucketCountError (ls , c )
414414 }
415415
416- if err , c := checkHistogramBuckets (histogramSample .GetPositiveDeltas (), & pCount , true ); err != nil {
416+ if c , err := checkHistogramBuckets (histogramSample .GetPositiveDeltas (), & pCount , true ); err != nil {
417417 validateMetrics .DiscardedSamples .WithLabelValues (nativeHistogramNegativeBucketCount , userID ).Inc ()
418418 return cortexpb.Histogram {}, newNativeHistogramNegativeBucketCountError (ls , c )
419419 }
@@ -499,9 +499,9 @@ func ValidateNativeHistogram(validateMetrics *ValidateMetrics, limits *Limits, u
499499}
500500
501501// copy from https://github.com/prometheus/prometheus/blob/v3.6.0/model/histogram/generic.go#L399-L420
502- func checkHistogramBuckets [BC histogram.BucketCount , IBC histogram.InternalBucketCount ](buckets []IBC , count * BC , deltas bool ) (error , float64 ) {
502+ func checkHistogramBuckets [BC histogram.BucketCount , IBC histogram.InternalBucketCount ](buckets []IBC , count * BC , deltas bool ) (float64 , error ) {
503503 if len (buckets ) == 0 {
504- return nil , 0
504+ return 0 , nil
505505 }
506506
507507 var last IBC
@@ -513,13 +513,13 @@ func checkHistogramBuckets[BC histogram.BucketCount, IBC histogram.InternalBucke
513513 c = buckets [i ]
514514 }
515515 if c < 0 {
516- return fmt .Errorf ("bucket number %d has observation count of %v" , i + 1 , c ), float64 ( c )
516+ return float64 ( c ), fmt .Errorf ("bucket number %d has observation count of %v" , i + 1 , c )
517517 }
518518 last = c
519519 * count += BC (c )
520520 }
521521
522- return nil , 0
522+ return 0 , nil
523523}
524524
525525func DeletePerUserValidationMetrics (validateMetrics * ValidateMetrics , userID string , log log.Logger ) {
0 commit comments