mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
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:
parent
bb00bae353
commit
d8c7cc266b
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user