@@ -1844,37 +1844,41 @@ type constNativeHistogram struct {
18441844 nativeHistogramSchema int32
18451845 nativeHistogramZeroThreshold float64
18461846 nativeHistogramMaxZeroThreshold float64
1847- createdTimestamp time.Time
1847+ createdTimestamp time.Time
18481848 nativeExemplars []* dto.Exemplar
18491849
18501850 positiveBuckets map [int ]int64
18511851 negativeBuckets map [int ]int64
18521852 zeroBucket uint64
18531853}
18541854
1855- func NewconstNativeHistogram (desc * Desc , count uint64 , sum float64 , postiveBuckets , negativeBuckets map [int ]int64 , zeroBucket uint64 ,
1856- labelPairs []* dto.LabelPair , nativeHistogramSchema int32 , nativeHistogramZeroThreshold float64 ,
1857- nativeHistogramMaxZeroThreshold float64 , nativeHistogramMaxBuckets uint32 ,
1858- nativeHistogramMinResetDuration time.Duration ,
1855+ func NewConstNativeHistogram (desc * Desc , count uint64 , sum float64 , postiveBuckets , negativeBuckets map [int ]int64 , zeroBucket uint64 ,
1856+ nativeHistogramSchema int32 , nativeHistogramZeroThreshold float64 ,
1857+ nativeHistogramMaxZeroThreshold float64 ,
18591858 createdTimestamp time.Time ,
18601859 nativeExemplars []* dto.Exemplar ,
1861- ) (constNativeHistogram , error ) {
1862- return constNativeHistogram {
1860+ labelValues ... string ,
1861+ ) (Metric , error ) {
1862+ if desc .err != nil {
1863+ return nil , desc .err
1864+ }
1865+ if err := validateLabelValues (labelValues , len (desc .variableLabels .names )); err != nil {
1866+ return nil , err
1867+ }
1868+ return & constNativeHistogram {
18631869 desc : desc ,
18641870 count : count ,
18651871 sum : sum ,
18661872 positiveBuckets : postiveBuckets ,
18671873 negativeBuckets : negativeBuckets ,
18681874 zeroBucket : zeroBucket ,
1869- labelPairs : labelPairs ,
1875+ labelPairs : MakeLabelPairs ( desc , labelValues ) ,
18701876 nativeHistogramSchema : nativeHistogramSchema ,
18711877 nativeHistogramZeroThreshold : nativeHistogramZeroThreshold ,
18721878 nativeHistogramMaxZeroThreshold : nativeHistogramMaxZeroThreshold ,
1873- nativeHistogramMaxBuckets : nativeHistogramMaxBuckets ,
1874- nativeHistogramMinResetDuration : nativeHistogramMinResetDuration ,
1875- timeStamp : timeStamp ,
1879+ createdTimestamp : createdTimestamp ,
18761880 nativeExemplars : nativeExemplars ,
1877- }
1881+ }, nil
18781882}
18791883
18801884func (h * constNativeHistogram ) Desc () * Desc {
@@ -1883,7 +1887,7 @@ func (h *constNativeHistogram) Desc() *Desc {
18831887
18841888func (h * constNativeHistogram ) Write (out * dto.Metric ) error {
18851889 his := & dto.Histogram {
1886- CreatedTimestamp : timestamppb .New (h .timeStamp ),
1890+ CreatedTimestamp : timestamppb .New (h .createdTimestamp ),
18871891 Schema : & h .nativeHistogramSchema ,
18881892 ZeroThreshold : & h .nativeHistogramZeroThreshold ,
18891893 Exemplars : h .nativeExemplars ,
0 commit comments