Add unit protobuf parser

Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
pull/13299/head
Arianna Vespri 12 months ago
parent db915b07cb
commit 5d5acf5744

@ -136,7 +136,6 @@ func (p *OpenMetricsParser) Type() ([]byte, MetricType) {
// Must only be called after Next returned a unit entry. // Must only be called after Next returned a unit entry.
// The returned byte slices become invalid after the next call to Next. // The returned byte slices become invalid after the next call to Next.
func (p *OpenMetricsParser) Unit() ([]byte, []byte) { func (p *OpenMetricsParser) Unit() ([]byte, []byte) {
// The Prometheus format does not have units.
return p.l.b[p.offsets[0]:p.offsets[1]], p.text return p.l.b[p.offsets[0]:p.offsets[1]], p.text
} }

@ -272,7 +272,7 @@ func (p *ProtobufParser) Type() ([]byte, MetricType) {
// Unit always returns (nil, nil) because units aren't supported by the protobuf // Unit always returns (nil, nil) because units aren't supported by the protobuf
// format. // format.
func (p *ProtobufParser) Unit() ([]byte, []byte) { func (p *ProtobufParser) Unit() ([]byte, []byte) {
return nil, nil return p.metricBytes.Bytes(), []byte(p.mf.GetUnit())
} }
// Comment always returns nil because comments aren't supported by the protobuf // Comment always returns nil because comments aren't supported by the protobuf

Loading…
Cancel
Save