From d8c7cc266b46f366c5f2b0e5ca4fc5d43e023a1b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 3 Jul 2024 16:08:03 +0200 Subject: [PATCH] lib/promscrape: use prompbmarshal.MustParsePromMetrics function at parseData() test function The prompbmarshal.MustParsePromMetrics function has been added in the commit cc4d57d6509196a42d6c674e387da0e20cc56da5 --- lib/promscrape/scrapework_test.go | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/lib/promscrape/scrapework_test.go b/lib/promscrape/scrapework_test.go index 52084f8ae..5467e725e 100644 --- a/lib/promscrape/scrapework_test.go +++ b/lib/promscrape/scrapework_test.go @@ -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 {