Add unit protobuf parser

Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
This commit is contained in:
Arianna Vespri 2023-12-12 12:40:08 +01:00
parent db915b07cb
commit 5d5acf5744
2 changed files with 1 additions and 2 deletions

View File

@ -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
} }

View File

@ -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