prometheus/pkg/textparse
Bryan Boreham 92a3eeac55
Create less garbage when parsing metrics (#9299)
* Refactor: extract function to make scrapeLoop for testing

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Add benchmarks for ScrapeLoopAppend

For Prometheus and OpenMetrics

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Create less garbage when parsing metrics

Exemplar escapes to heap due to being passed through text-parser
interface, but we can reduce the impact by hoisting it out of the loop
and resetting it after every use.

(Note the cost was paid on every line even when exemplars were disabled)

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Create less garbage when parsing OpenMetrics

After calling parseLVals() we always append the return value, so pass in
what we want to append it to and save garbage.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2021-09-08 13:39:21 +05:30
..
README.md Add a README.md to textparse package about how to update lexers. 2019-10-23 23:55:42 -07:00
interface.go Refactor test assertions (#8110) 2020-10-27 11:06:53 +01:00
openmetricslex.l Fix golint issues. 2020-03-23 20:38:43 +01:00
openmetricslex.l.go Fix golint issues. 2020-03-23 20:38:43 +01:00
openmetricsparse.go Create less garbage when parsing metrics (#9299) 2021-09-08 13:39:21 +05:30
openmetricsparse_test.go Return error on NaN and Inf timestamps for OpenMetrics parser 2021-06-28 20:55:04 -04:00
promlex.l Prepare for multiple text formats 2018-10-18 13:58:00 +01:00
promlex.l.go Add exemplar support to the openmetrics parser (#6292) 2019-11-19 09:33:30 +00:00
promparse.go Fix golint issues. 2020-03-23 20:38:43 +01:00
promparse_test.go Testify: move to require (#8122) 2020-10-29 09:43:23 +00:00
promtestdata.nometa.txt Add an OpenMetrics parser. 2018-10-18 13:58:00 +01:00
promtestdata.txt Add an OpenMetrics parser. 2018-10-18 13:58:00 +01:00

README.md

Making changes to textparse lexers

In the rare case that you need to update the textparse lexers, edit promlex.l or openmetricslex.l and then run the following command: golex -o=promlex.l.go promlex.l

Note that you need golex installed: go get -u modernc.org/golex