lib/promscrape: use prompbmarshal.MustParsePromMetrics function at parseData() test function

The prompbmarshal.MustParsePromMetrics function has been added in the commit cc4d57d650
This commit is contained in:
Aliaksandr Valialkin 2024-07-03 16:08:03 +02:00
parent bb00bae353
commit d8c7cc266b
No known key found for this signature in database
GPG Key ID: 52C003EE2BCDB9EB

View File

@ -775,36 +775,7 @@ func parsePromRow(data string) *parser.Row {
}
func parseData(data string) []prompbmarshal.TimeSeries {
var rows parser.Rows
errLogger := func(s string) {
panic(fmt.Errorf("unexpected error when unmarshaling Prometheus rows: %s", s))
}
rows.UnmarshalWithErrLogger(data, errLogger)
var tss []prompbmarshal.TimeSeries
for _, r := range rows.Rows {
labels := []prompbmarshal.Label{
{
Name: "__name__",
Value: r.Metric,
},
}
for _, tag := range r.Tags {
labels = append(labels, prompbmarshal.Label{
Name: tag.Key,
Value: tag.Value,
})
}
var ts prompbmarshal.TimeSeries
ts.Labels = labels
ts.Samples = []prompbmarshal.Sample{
{
Value: r.Value,
Timestamp: r.Timestamp,
},
}
tss = append(tss, ts)
}
return tss
return prompbmarshal.MustParsePromMetrics(data, 0)
}
func expectEqualTimeseries(tss, tssExpected []prompbmarshal.TimeSeries) error {