@@ -956,13 +956,13 @@ func (h *histogram) limitBuckets(counts *histogramCounts, value float64, bucket
956
956
// h.nativeHistogramMinResetDuration has been passed. It returns true if the
957
957
// histogram has been reset. The caller must have locked h.mtx.
958
958
func (h * histogram ) maybeReset (
959
- hot , cold * histogramCounts , coldIdx uint64 , value float64 , bucket int ,
959
+ hot , cold * histogramCounts , coldIdx uint64 , value float64 , bucket int ,
960
960
) bool {
961
961
// We are using the possibly mocked h.now() rather than
962
962
// time.Since(h.lastResetTime) to enable testing.
963
963
if h .nativeHistogramMinResetDuration == 0 || // No reset configured.
964
- h .resetScheduled || // Do not interefere if a reset is already scheduled.
965
- h .now ().Sub (h .lastResetTime ) < h .nativeHistogramMinResetDuration {
964
+ h .resetScheduled || // Do not interefere if a reset is already scheduled.
965
+ h .now ().Sub (h .lastResetTime ) < h .nativeHistogramMinResetDuration {
966
966
return false
967
967
}
968
968
// Completely reset coldCounts.
@@ -1355,11 +1355,11 @@ func (h *constHistogram) Write(out *dto.Metric) error {
1355
1355
// NewConstHistogram returns an error if the length of labelValues is not
1356
1356
// consistent with the variable labels in Desc or if Desc is invalid.
1357
1357
func NewConstHistogram (
1358
- desc * Desc ,
1359
- count uint64 ,
1360
- sum float64 ,
1361
- buckets map [float64 ]uint64 ,
1362
- labelValues ... string ,
1358
+ desc * Desc ,
1359
+ count uint64 ,
1360
+ sum float64 ,
1361
+ buckets map [float64 ]uint64 ,
1362
+ labelValues ... string ,
1363
1363
) (Metric , error ) {
1364
1364
if desc .err != nil {
1365
1365
return nil , desc .err
@@ -1379,11 +1379,11 @@ func NewConstHistogram(
1379
1379
// MustNewConstHistogram is a version of NewConstHistogram that panics where
1380
1380
// NewConstHistogram would have returned an error.
1381
1381
func MustNewConstHistogram (
1382
- desc * Desc ,
1383
- count uint64 ,
1384
- sum float64 ,
1385
- buckets map [float64 ]uint64 ,
1386
- labelValues ... string ,
1382
+ desc * Desc ,
1383
+ count uint64 ,
1384
+ sum float64 ,
1385
+ buckets map [float64 ]uint64 ,
1386
+ labelValues ... string ,
1387
1387
) Metric {
1388
1388
m , err := NewConstHistogram (desc , count , sum , buckets , labelValues ... )
1389
1389
if err != nil {
@@ -1394,12 +1394,12 @@ func MustNewConstHistogram(
1394
1394
1395
1395
// NewConstHistogramWithCreatedTimestamp does the same thing as NewConstHistogram but sets the created timestamp.
1396
1396
func NewConstHistogramWithCreatedTimestamp (
1397
- desc * Desc ,
1398
- count uint64 ,
1399
- sum float64 ,
1400
- buckets map [float64 ]uint64 ,
1401
- ct time.Time ,
1402
- labelValues ... string ,
1397
+ desc * Desc ,
1398
+ count uint64 ,
1399
+ sum float64 ,
1400
+ buckets map [float64 ]uint64 ,
1401
+ ct time.Time ,
1402
+ labelValues ... string ,
1403
1403
) (Metric , error ) {
1404
1404
if desc .err != nil {
1405
1405
return nil , desc .err
@@ -1420,12 +1420,12 @@ func NewConstHistogramWithCreatedTimestamp(
1420
1420
// MustNewConstHistogramWithCreatedTimestamp is a version of NewConstHistogramWithCreatedTimestamp that panics where
1421
1421
// NewConstHistogramWithCreatedTimestamp would have returned an error.
1422
1422
func MustNewConstHistogramWithCreatedTimestamp (
1423
- desc * Desc ,
1424
- count uint64 ,
1425
- sum float64 ,
1426
- buckets map [float64 ]uint64 ,
1427
- ct time.Time ,
1428
- labelValues ... string ,
1423
+ desc * Desc ,
1424
+ count uint64 ,
1425
+ sum float64 ,
1426
+ buckets map [float64 ]uint64 ,
1427
+ ct time.Time ,
1428
+ labelValues ... string ,
1429
1429
) Metric {
1430
1430
m , err := NewConstHistogramWithCreatedTimestamp (desc , count , sum , buckets , ct , labelValues ... )
1431
1431
if err != nil {
@@ -1873,7 +1873,7 @@ func validateCount(sum float64, count uint64, negativeBuckets, positiveBuckets m
1873
1873
// Otherwise, the number of observations must be equal to the sum of all bucket counts .
1874
1874
1875
1875
if math .IsNaN (sum ) && bucketPopulationSum > int64 (count ) ||
1876
- ! math .IsNaN (sum ) && bucketPopulationSum != int64 (count ) {
1876
+ ! math .IsNaN (sum ) && bucketPopulationSum != int64 (count ) {
1877
1877
return errors .New ("the sum of all bucket populations exceeds the count of observations" )
1878
1878
}
1879
1879
return nil
@@ -1902,15 +1902,15 @@ func validateCount(sum float64, count uint64, negativeBuckets, positiveBuckets m
1902
1902
//
1903
1903
// See https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#exponential-histograms for more details about the conversion from OTel to Prometheus.
1904
1904
func NewConstNativeHistogram (
1905
- desc * Desc ,
1906
- count uint64 ,
1907
- sum float64 ,
1908
- positiveBuckets , negativeBuckets map [int ]int64 ,
1909
- zeroBucket uint64 ,
1910
- schema int32 ,
1911
- zeroThreshold float64 ,
1912
- createdTimestamp time.Time ,
1913
- labelValues ... string ,
1905
+ desc * Desc ,
1906
+ count uint64 ,
1907
+ sum float64 ,
1908
+ positiveBuckets , negativeBuckets map [int ]int64 ,
1909
+ zeroBucket uint64 ,
1910
+ schema int32 ,
1911
+ zeroThreshold float64 ,
1912
+ createdTimestamp time.Time ,
1913
+ labelValues ... string ,
1914
1914
) (Metric , error ) {
1915
1915
if desc .err != nil {
1916
1916
return nil , desc .err
@@ -1958,15 +1958,15 @@ func NewConstNativeHistogram(
1958
1958
// MustNewConstNativeHistogram is a version of NewConstNativeHistogram that panics where
1959
1959
// NewConstNativeHistogram would have returned an error.
1960
1960
func MustNewConstNativeHistogram (
1961
- desc * Desc ,
1962
- count uint64 ,
1963
- sum float64 ,
1964
- positiveBuckets , negativeBuckets map [int ]int64 ,
1965
- zeroBucket uint64 ,
1966
- nativeHistogramSchema int32 ,
1967
- nativeHistogramZeroThreshold float64 ,
1968
- createdTimestamp time.Time ,
1969
- labelValues ... string ,
1961
+ desc * Desc ,
1962
+ count uint64 ,
1963
+ sum float64 ,
1964
+ positiveBuckets , negativeBuckets map [int ]int64 ,
1965
+ zeroBucket uint64 ,
1966
+ nativeHistogramSchema int32 ,
1967
+ nativeHistogramZeroThreshold float64 ,
1968
+ createdTimestamp time.Time ,
1969
+ labelValues ... string ,
1970
1970
) Metric {
1971
1971
nativehistogram , err := NewConstNativeHistogram (desc ,
1972
1972
count ,
0 commit comments