From d758198e375513ad1168c05f7bb612f50e7bcac9 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Wed, 29 Jun 2022 18:44:15 +0200 Subject: [PATCH] prompb: Update exposition protobuf to include float and gauge histograms Signed-off-by: beorn7 --- prompb/io/prometheus/client/metrics.pb.go | 353 ++++++++++++++++------ prompb/io/prometheus/client/metrics.proto | 69 +++-- 2 files changed, 311 insertions(+), 111 deletions(-) diff --git a/prompb/io/prometheus/client/metrics.pb.go b/prompb/io/prometheus/client/metrics.pb.go index 2e7f7b390..48f68ec19 100644 --- a/prompb/io/prometheus/client/metrics.pb.go +++ b/prompb/io/prometheus/client/metrics.pb.go @@ -28,11 +28,18 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MetricType int32 const ( - MetricType_COUNTER MetricType = 0 - MetricType_GAUGE MetricType = 1 - MetricType_SUMMARY MetricType = 2 - MetricType_UNTYPED MetricType = 3 + // COUNTER must use the Metric field "counter". + MetricType_COUNTER MetricType = 0 + // GAUGE must use the Metric field "gauge". + MetricType_GAUGE MetricType = 1 + // SUMMARY must use the Metric field "summary". + MetricType_SUMMARY MetricType = 2 + // UNTYPED must use the Metric field "untyped". + MetricType_UNTYPED MetricType = 3 + // HISTOGRAM must use the Metric field "histogram". MetricType_HISTOGRAM MetricType = 4 + // GAUGE_HISTOGRAM must use the Metric field "histogram". + MetricType_GAUGE_HISTOGRAM MetricType = 5 ) var MetricType_name = map[int32]string{ @@ -41,14 +48,16 @@ var MetricType_name = map[int32]string{ 2: "SUMMARY", 3: "UNTYPED", 4: "HISTOGRAM", + 5: "GAUGE_HISTOGRAM", } var MetricType_value = map[string]int32{ - "COUNTER": 0, - "GAUGE": 1, - "SUMMARY": 2, - "UNTYPED": 3, - "HISTOGRAM": 4, + "COUNTER": 0, + "GAUGE": 1, + "SUMMARY": 2, + "UNTYPED": 3, + "HISTOGRAM": 4, + "GAUGE_HISTOGRAM": 5, } func (x MetricType) String() string { @@ -382,9 +391,10 @@ func (m *Untyped) GetValue() float64 { } type Histogram struct { - SampleCount uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount,proto3" json:"sample_count,omitempty"` - SampleSum float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum,proto3" json:"sample_sum,omitempty"` - Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket,proto3" json:"bucket,omitempty"` + SampleCount uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount,proto3" json:"sample_count,omitempty"` + SampleCountFloat float64 `protobuf:"fixed64,9,opt,name=sample_count_float,json=sampleCountFloat,proto3" json:"sample_count_float,omitempty"` + SampleSum float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum,proto3" json:"sample_sum,omitempty"` + Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket,proto3" json:"bucket,omitempty"` // Sparse bucket (sb) stuff: // The sb_schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8. // They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and @@ -394,6 +404,7 @@ type Histogram struct { SbSchema int32 `protobuf:"zigzag32,4,opt,name=sb_schema,json=sbSchema,proto3" json:"sb_schema,omitempty"` SbZeroThreshold float64 `protobuf:"fixed64,5,opt,name=sb_zero_threshold,json=sbZeroThreshold,proto3" json:"sb_zero_threshold,omitempty"` SbZeroCount uint64 `protobuf:"varint,6,opt,name=sb_zero_count,json=sbZeroCount,proto3" json:"sb_zero_count,omitempty"` + SbZeroCountFloat float64 `protobuf:"fixed64,10,opt,name=sb_zero_count_float,json=sbZeroCountFloat,proto3" json:"sb_zero_count_float,omitempty"` SbNegative *SparseBuckets `protobuf:"bytes,7,opt,name=sb_negative,json=sbNegative,proto3" json:"sb_negative,omitempty"` SbPositive *SparseBuckets `protobuf:"bytes,8,opt,name=sb_positive,json=sbPositive,proto3" json:"sb_positive,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -441,6 +452,13 @@ func (m *Histogram) GetSampleCount() uint64 { return 0 } +func (m *Histogram) GetSampleCountFloat() float64 { + if m != nil { + return m.SampleCountFloat + } + return 0 +} + func (m *Histogram) GetSampleSum() float64 { if m != nil { return m.SampleSum @@ -476,6 +494,13 @@ func (m *Histogram) GetSbZeroCount() uint64 { return 0 } +func (m *Histogram) GetSbZeroCountFloat() float64 { + if m != nil { + return m.SbZeroCountFloat + } + return 0 +} + func (m *Histogram) GetSbNegative() *SparseBuckets { if m != nil { return m.SbNegative @@ -492,6 +517,7 @@ func (m *Histogram) GetSbPositive() *SparseBuckets { type Bucket struct { CumulativeCount uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount,proto3" json:"cumulative_count,omitempty"` + CumulativeCountFloat float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat,proto3" json:"cumulative_count_float,omitempty"` UpperBound float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound,proto3" json:"upper_bound,omitempty"` Exemplar *Exemplar `protobuf:"bytes,3,opt,name=exemplar,proto3" json:"exemplar,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -539,6 +565,13 @@ func (m *Bucket) GetCumulativeCount() uint64 { return 0 } +func (m *Bucket) GetCumulativeCountFloat() float64 { + if m != nil { + return m.CumulativeCountFloat + } + return 0 +} + func (m *Bucket) GetUpperBound() float64 { if m != nil { return m.UpperBound @@ -554,11 +587,14 @@ func (m *Bucket) GetExemplar() *Exemplar { } type SparseBuckets struct { - Span []*SparseBuckets_Span `protobuf:"bytes,1,rep,name=span,proto3" json:"span,omitempty"` - Delta []int64 `protobuf:"zigzag64,2,rep,packed,name=delta,proto3" json:"delta,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Span []*SparseBuckets_Span `protobuf:"bytes,1,rep,name=span,proto3" json:"span,omitempty"` + // Only one of "delta" or "count" may be used, the former for regular + // histograms with integer counts, the latter for float histograms. + Delta []int64 `protobuf:"zigzag64,2,rep,packed,name=delta,proto3" json:"delta,omitempty"` + Count []float64 `protobuf:"fixed64,3,rep,packed,name=count,proto3" json:"count,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SparseBuckets) Reset() { *m = SparseBuckets{} } @@ -608,6 +644,19 @@ func (m *SparseBuckets) GetDelta() []int64 { return nil } +func (m *SparseBuckets) GetCount() []float64 { + if m != nil { + return m.Count + } + return nil +} + +// A Span is a given number of consecutive buckets at a given +// offset. Logically, it would be more straightforward to include +// the bucket counts in the Span. However, the protobuf +// representation is more compact in the way the data is structured +// here (with all the buckets in a single array separate from the +// Spans). type SparseBuckets_Span struct { Offset int32 `protobuf:"zigzag32,1,opt,name=offset,proto3" json:"offset,omitempty"` Length uint32 `protobuf:"varint,2,opt,name=length,proto3" json:"length,omitempty"` @@ -914,60 +963,65 @@ func init() { } var fileDescriptor_d1e5ddb18987a258 = []byte{ - // 848 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xc7, 0x89, 0xf3, 0xc7, 0x2f, 0x5d, 0x9a, 0x1d, 0xad, 0x90, 0xb5, 0x65, 0x77, 0x83, 0xb9, - 0x2c, 0x3d, 0x38, 0xa2, 0xb4, 0x80, 0x50, 0x39, 0xec, 0xb6, 0x21, 0x45, 0x22, 0xdb, 0x65, 0x92, - 0x1c, 0x5a, 0x0e, 0xd6, 0x38, 0x99, 0x4d, 0x2c, 0x3c, 0x1e, 0xe3, 0xb1, 0x2b, 0xc2, 0x17, 0xe0, - 0x0a, 0x67, 0x6e, 0x7c, 0x1a, 0x8e, 0x7c, 0x04, 0xb4, 0x9f, 0x03, 0x09, 0x34, 0x7f, 0xec, 0x10, - 0xc9, 0x41, 0x14, 0xf5, 0xe6, 0xf7, 0xfc, 0xfb, 0xbd, 0xf9, 0xbd, 0x37, 0x33, 0xbf, 0x01, 0x2f, - 0xe2, 0xc3, 0x34, 0xe3, 0x8c, 0xe6, 0x6b, 0x5a, 0x88, 0xe1, 0x22, 0x8e, 0x68, 0x92, 0x0f, 0x19, - 0xcd, 0xb3, 0x68, 0x21, 0xfc, 0x34, 0xe3, 0x39, 0x47, 0x47, 0x11, 0xf7, 0xb7, 0x18, 0x5f, 0x63, - 0x8e, 0xcf, 0x56, 0x9c, 0xaf, 0x62, 0x3a, 0x54, 0x98, 0xb0, 0xb8, 0x19, 0xe6, 0x11, 0xa3, 0x22, - 0x27, 0x2c, 0xd5, 0x34, 0xef, 0x11, 0x38, 0x5f, 0x91, 0x90, 0xc6, 0xd7, 0x24, 0xca, 0x10, 0x02, - 0x3b, 0x21, 0x8c, 0xba, 0xd6, 0xc0, 0x3a, 0x77, 0xb0, 0xfa, 0x46, 0x47, 0xd0, 0x7a, 0x45, 0xe2, - 0x82, 0xba, 0x0d, 0x95, 0xd4, 0x81, 0x77, 0x02, 0xad, 0x31, 0x29, 0x56, 0xff, 0xf8, 0x2d, 0x39, - 0x56, 0xf9, 0xfb, 0x1b, 0xe8, 0x3c, 0xe1, 0x45, 0x92, 0xd3, 0xac, 0x1e, 0x80, 0x3e, 0x83, 0x2e, - 0xfd, 0x9e, 0xb2, 0x34, 0x26, 0x99, 0x2a, 0xdc, 0x7b, 0x70, 0xea, 0xd7, 0x35, 0xe0, 0x8f, 0x0c, - 0x0a, 0x57, 0x78, 0xef, 0x31, 0x74, 0xbf, 0x2e, 0x48, 0x92, 0x47, 0x31, 0x45, 0xc7, 0xd0, 0xfd, - 0xce, 0x7c, 0x9b, 0x05, 0xaa, 0x78, 0x57, 0x79, 0x25, 0xed, 0x47, 0x0b, 0x3a, 0xd3, 0x82, 0x31, - 0x92, 0x6d, 0xd0, 0x7b, 0x70, 0x47, 0x10, 0x96, 0xc6, 0x34, 0x58, 0x48, 0xb5, 0xaa, 0x82, 0x8d, - 0x7b, 0x3a, 0xa7, 0x1a, 0x40, 0x27, 0x00, 0x06, 0x22, 0x0a, 0x66, 0x2a, 0x39, 0x3a, 0x33, 0x2d, - 0x98, 0xec, 0xa3, 0x5a, 0xbf, 0x39, 0x68, 0xee, 0xef, 0xa3, 0x54, 0xbc, 0xd5, 0xe7, 0x9d, 0x41, - 0x67, 0x9e, 0xe4, 0x9b, 0x94, 0x2e, 0xf7, 0x4c, 0xf1, 0xcf, 0x06, 0x38, 0xcf, 0x22, 0x91, 0xf3, - 0x55, 0x46, 0xd8, 0x1b, 0x10, 0xfb, 0x10, 0xda, 0x61, 0xb1, 0xf8, 0x96, 0xe6, 0x46, 0xea, 0xbb, - 0xf5, 0x52, 0x2f, 0x15, 0x06, 0x1b, 0x2c, 0xba, 0x07, 0x8e, 0x08, 0x03, 0xb1, 0x58, 0x53, 0x46, - 0x5c, 0x7b, 0x60, 0x9d, 0x1f, 0xe2, 0xae, 0x08, 0xa7, 0x2a, 0x46, 0xf7, 0xe1, 0x50, 0x84, 0xc1, - 0x0f, 0x34, 0xe3, 0x41, 0xbe, 0xce, 0xa8, 0x58, 0xf3, 0x78, 0xe9, 0xb6, 0xd4, 0xc2, 0x77, 0x45, - 0xf8, 0x92, 0x66, 0x7c, 0x56, 0xa6, 0x91, 0x07, 0x07, 0x25, 0x56, 0x77, 0xd0, 0x36, 0x1d, 0x28, - 0x9c, 0xee, 0xe0, 0x29, 0xf4, 0x44, 0x18, 0x24, 0x74, 0x45, 0xf2, 0xe8, 0x15, 0x75, 0x3b, 0xea, - 0x68, 0xbc, 0x5f, 0xaf, 0x73, 0x9a, 0x92, 0x4c, 0x50, 0xad, 0x56, 0x60, 0x10, 0xe1, 0x95, 0xa1, - 0x99, 0x2a, 0x29, 0x17, 0x91, 0xaa, 0xd2, 0x7d, 0xad, 0x2a, 0xd7, 0x86, 0xe6, 0xfd, 0x64, 0x41, - 0x5b, 0xe7, 0xd1, 0x07, 0xd0, 0x5f, 0x14, 0xac, 0x88, 0x55, 0xf9, 0x9d, 0xf9, 0xdf, 0xdd, 0xe6, - 0x75, 0x07, 0x67, 0xd0, 0x2b, 0xd2, 0x94, 0x66, 0x41, 0xc8, 0x8b, 0x64, 0x69, 0x36, 0x01, 0x54, - 0xea, 0x52, 0x66, 0x76, 0x8e, 0x7e, 0xf3, 0x35, 0x8f, 0xfe, 0x2f, 0x16, 0x1c, 0xec, 0x08, 0x46, - 0x8f, 0xc1, 0x16, 0x29, 0x49, 0x5c, 0x4b, 0xed, 0xe8, 0xf9, 0x7f, 0xe8, 0x51, 0x46, 0x09, 0x56, - 0x2c, 0x79, 0xee, 0x96, 0x34, 0xce, 0x89, 0xdb, 0x18, 0x34, 0xcf, 0x11, 0xd6, 0xc1, 0xf1, 0xc7, - 0x60, 0x4b, 0x0c, 0x7a, 0x07, 0xda, 0xfc, 0xe6, 0x46, 0x50, 0xdd, 0xeb, 0x21, 0x36, 0x91, 0xcc, - 0xc7, 0x34, 0x59, 0xe5, 0x6b, 0xd5, 0xdd, 0x01, 0x36, 0x91, 0xf7, 0xb3, 0x05, 0xdd, 0x52, 0x34, - 0x7a, 0x04, 0xad, 0x58, 0x1a, 0x8b, 0x51, 0x76, 0x56, 0xaf, 0xac, 0xf2, 0x1e, 0xac, 0xd1, 0xf5, - 0x97, 0x16, 0x7d, 0x0a, 0x4e, 0x65, 0x5c, 0x66, 0x68, 0xc7, 0xbe, 0xb6, 0x36, 0xbf, 0xb4, 0x36, - 0x7f, 0x56, 0x22, 0xf0, 0x16, 0xec, 0xfd, 0xd5, 0x80, 0xf6, 0x44, 0x19, 0xe5, 0xff, 0x55, 0xf4, - 0x21, 0xb4, 0x56, 0xd2, 0xea, 0x8c, 0x4f, 0xdd, 0xab, 0xa7, 0x29, 0x37, 0xc4, 0x1a, 0x89, 0x3e, - 0x81, 0xce, 0x42, 0xdb, 0x9f, 0x11, 0x7b, 0x52, 0x4f, 0x32, 0x1e, 0x89, 0x4b, 0xb4, 0x24, 0x0a, - 0xed,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0x07, 0x5b, 0x05, 0x81, 0x56, 0x10, 0xb6, 0xd5, 0xc1, - 0xfd, 0xe8, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x94, 0x4a, 0x80, 0xdd, 0x07, 0x00, 0x00, + // 913 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdd, 0x72, 0xdb, 0x44, + 0x14, 0x46, 0xb1, 0xfc, 0xa3, 0xe3, 0x86, 0x38, 0xdb, 0x4c, 0x47, 0x93, 0x92, 0xc4, 0x88, 0x9b, + 0xd0, 0x01, 0x7b, 0x28, 0x29, 0x30, 0x4c, 0xb9, 0x48, 0xda, 0x34, 0x65, 0x06, 0xa7, 0x61, 0x6d, + 0x5f, 0xb4, 0x5c, 0x68, 0x56, 0xce, 0xc6, 0xd6, 0x20, 0x69, 0x85, 0x76, 0xd5, 0xc1, 0xbc, 0x00, + 0xd7, 0xbc, 0x02, 0x6f, 0xc0, 0x4b, 0x30, 0x5c, 0x72, 0xcb, 0x1d, 0x93, 0x17, 0x81, 0xd9, 0x1f, + 0x49, 0x71, 0x47, 0x86, 0xb6, 0x77, 0x3e, 0xc7, 0xdf, 0x77, 0xf4, 0x7d, 0x47, 0xbb, 0x9f, 0xc0, + 0x0b, 0xd9, 0x30, 0xcd, 0x58, 0x4c, 0xc5, 0x82, 0xe6, 0x7c, 0x38, 0x8b, 0x42, 0x9a, 0x88, 0x61, + 0x4c, 0x45, 0x16, 0xce, 0xf8, 0x20, 0xcd, 0x98, 0x60, 0x68, 0x27, 0x64, 0x83, 0x0a, 0x33, 0xd0, + 0x98, 0xdd, 0x83, 0x39, 0x63, 0xf3, 0x88, 0x0e, 0x15, 0x26, 0xc8, 0xaf, 0x86, 0x22, 0x8c, 0x29, + 0x17, 0x24, 0x4e, 0x35, 0xcd, 0x7b, 0x00, 0xce, 0x37, 0x24, 0xa0, 0xd1, 0x05, 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, 0xaf, 0xf7, 0xad, 0x17, 0x3b, 0x21, 0xf3, 0x2b, 0x59, 0xbe, 0x96, 0x15, 0xb4, 0xd4, + 0x69, 0xfe, 0xf4, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x06, 0x77, 0x31, 0x97, 0x9b, 0x08, 0x00, + 0x00, } func (m *LabelPair) Marshal() (dAtA []byte, err error) { @@ -1237,6 +1291,18 @@ func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.SbZeroCountFloat != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.SbZeroCountFloat)))) + i-- + dAtA[i] = 0x51 + } + if m.SampleCountFloat != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.SampleCountFloat)))) + i-- + dAtA[i] = 0x49 + } if m.SbPositive != nil { { size, err := m.SbPositive.MarshalToSizedBuffer(dAtA[:i]) @@ -1329,6 +1395,12 @@ func (m *Bucket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.CumulativeCountFloat != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.CumulativeCountFloat)))) + i-- + dAtA[i] = 0x21 + } if m.Exemplar != nil { { size, err := m.Exemplar.MarshalToSizedBuffer(dAtA[:i]) @@ -1379,22 +1451,32 @@ func (m *SparseBuckets) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Delta) > 0 { - var j5 int - dAtA7 := make([]byte, len(m.Delta)*10) - for _, num := range m.Delta { - x6 := (uint64(num) << 1) ^ uint64((num >> 63)) - for x6 >= 1<<7 { - dAtA7[j5] = uint8(uint64(x6)&0x7f | 0x80) - j5++ - x6 >>= 7 - } - dAtA7[j5] = uint8(x6) - j5++ + if len(m.Count) > 0 { + for iNdEx := len(m.Count) - 1; iNdEx >= 0; iNdEx-- { + f5 := math.Float64bits(float64(m.Count[iNdEx])) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f5)) } - i -= j5 - copy(dAtA[i:], dAtA7[:j5]) - i = encodeVarintMetrics(dAtA, i, uint64(j5)) + i = encodeVarintMetrics(dAtA, i, uint64(len(m.Count)*8)) + i-- + dAtA[i] = 0x1a + } + if len(m.Delta) > 0 { + var j6 int + dAtA8 := make([]byte, len(m.Delta)*10) + for _, num := range m.Delta { + x7 := (uint64(num) << 1) ^ uint64((num >> 63)) + for x7 >= 1<<7 { + dAtA8[j6] = uint8(uint64(x7)&0x7f | 0x80) + j6++ + x7 >>= 7 + } + dAtA8[j6] = uint8(x7) + j6++ + } + i -= j6 + copy(dAtA[i:], dAtA8[:j6]) + i = encodeVarintMetrics(dAtA, i, uint64(j6)) i-- dAtA[i] = 0x12 } @@ -1834,6 +1916,12 @@ func (m *Histogram) Size() (n int) { l = m.SbPositive.Size() n += 1 + l + sovMetrics(uint64(l)) } + if m.SampleCountFloat != 0 { + n += 9 + } + if m.SbZeroCountFloat != 0 { + n += 9 + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1856,6 +1944,9 @@ func (m *Bucket) Size() (n int) { l = m.Exemplar.Size() n += 1 + l + sovMetrics(uint64(l)) } + if m.CumulativeCountFloat != 0 { + n += 9 + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1881,6 +1972,9 @@ func (m *SparseBuckets) Size() (n int) { } n += 1 + sovMetrics(uint64(l)) + l } + if len(m.Count) > 0 { + n += 1 + sovMetrics(uint64(len(m.Count)*8)) + len(m.Count)*8 + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -2747,6 +2841,28 @@ func (m *Histogram) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 9: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field SampleCountFloat", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.SampleCountFloat = float64(math.Float64frombits(v)) + case 10: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field SbZeroCountFloat", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.SbZeroCountFloat = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipMetrics(dAtA[iNdEx:]) @@ -2864,6 +2980,17 @@ func (m *Bucket) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field CumulativeCountFloat", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.CumulativeCountFloat = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipMetrics(dAtA[iNdEx:]) @@ -3027,6 +3154,60 @@ func (m *SparseBuckets) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field Delta", wireType) } + case 3: + if wireType == 1 { + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + v2 := float64(math.Float64frombits(v)) + m.Count = append(m.Count, v2) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetrics + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthMetrics + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthMetrics + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Count) == 0 { + m.Count = make([]float64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + v2 := float64(math.Float64frombits(v)) + m.Count = append(m.Count, v2) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } default: iNdEx = preIndex skippy, err := skipMetrics(dAtA[iNdEx:]) diff --git a/prompb/io/prometheus/client/metrics.proto b/prompb/io/prometheus/client/metrics.proto index 694c2c180..f0a0f40c4 100644 --- a/prompb/io/prometheus/client/metrics.proto +++ b/prompb/io/prometheus/client/metrics.proto @@ -29,11 +29,18 @@ message LabelPair { } enum MetricType { - COUNTER = 0; - GAUGE = 1; - SUMMARY = 2; - UNTYPED = 3; - HISTOGRAM = 4; + // COUNTER must use the Metric field "counter". + COUNTER = 0; + // GAUGE must use the Metric field "gauge". + GAUGE = 1; + // SUMMARY must use the Metric field "summary". + SUMMARY = 2; + // UNTYPED must use the Metric field "untyped". + UNTYPED = 3; + // HISTOGRAM must use the Metric field "histogram". + HISTOGRAM = 4; + // GAUGE_HISTOGRAM must use the Metric field "histogram". + GAUGE_HISTOGRAM = 5; } message Gauge { @@ -62,6 +69,7 @@ message Untyped { message Histogram { uint64 sample_count = 1; + double sample_count_float = 9; // Overrides sample_count if > 0. double sample_sum = 2; repeated Bucket bucket = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional. // Sparse bucket (sb) stuff: @@ -70,26 +78,37 @@ message Histogram { // then each power of two is divided into 2^n logarithmic buckets. // Or in other words, each bucket boundary is the previous boundary times 2^(2^-n). // In the future, more bucket schemas may be added using numbers < -4 or > 8. - sint32 sb_schema = 4; - double sb_zero_threshold = 5; // Breadth of the zero bucket. - uint64 sb_zero_count = 6; // Count in zero bucket. - SparseBuckets sb_negative = 7; // Negative sparse buckets. - SparseBuckets sb_positive = 8; // Positive sparse buckets. + sint32 sb_schema = 4; + double sb_zero_threshold = 5; // Breadth of the zero bucket. + uint64 sb_zero_count = 6; // Count in zero bucket. + double sb_zero_count_float = 10; // Overrides sb_zero_count if > 0. + SparseBuckets sb_negative = 7; // Negative sparse buckets. + SparseBuckets sb_positive = 8; // Positive sparse buckets. } message Bucket { - uint64 cumulative_count = 1; // Cumulative in increasing order. - double upper_bound = 2; // Inclusive. - Exemplar exemplar = 3; + uint64 cumulative_count = 1; // Cumulative in increasing order. + double cumulative_count_float = 4; // Overrides cumulative_count if > 0. + double upper_bound = 2; // Inclusive. + Exemplar exemplar = 3; } message SparseBuckets { + // A Span is a given number of consecutive buckets at a given + // offset. Logically, it would be more straightforward to include + // the bucket counts in the Span. However, the protobuf + // representation is more compact in the way the data is structured + // here (with all the buckets in a single array separate from the + // Spans). message Span { sint32 offset = 1; // Gap to previous span, or starting point for 1st span (which can be negative). uint32 length = 2; // Length of consecutive buckets. } - repeated Span span = 1; + repeated Span span = 1; + // Only one of "delta" or "count" may be used, the former for regular + // histograms with integer counts, the latter for float histograms. repeated sint64 delta = 2; // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + repeated double count = 3; // Absolute count of each bucket. } message Exemplar { @@ -99,18 +118,18 @@ message Exemplar { } message Metric { - repeated LabelPair label = 1; - Gauge gauge = 2; - Counter counter = 3; - Summary summary = 4; - Untyped untyped = 5; - Histogram histogram = 7; - int64 timestamp_ms = 6; + repeated LabelPair label = 1; + Gauge gauge = 2; + Counter counter = 3; + Summary summary = 4; + Untyped untyped = 5; + Histogram histogram = 7; + int64 timestamp_ms = 6; } message MetricFamily { - string name = 1; - string help = 2; - MetricType type = 3; - repeated Metric metric = 4; + string name = 1; + string help = 2; + MetricType type = 3; + repeated Metric metric = 4; }