Consider support for testing exemplars in prometheus/testutil
dashpole opened this issue · 4 comments
Context: open-telemetry/opentelemetry-go#5111
I am in the process of adding exemplar support to the OpenTelemetry-go prometheus exporter. We currently use testutil.GatherAndCompare for most of our testing, as it makes it easy to tell if the output is correct.
However, since GatherAndCompare currently uses the Prometheus text format, and the Prometheus text format doesn't support exemplars, I can't test using the same mechanism. Assuming exemplars aren't coming to the text format soon, the options to resolve this are:
- Re-implement GatherAndCompare in my own tests, and make it use OpenMetrics text format, instead of the Prometheus text format.
- Write unit test assertions on the go-protobuf types from
prometheus.Metric.Write()
to check for exemplars separately. - Extend testutil to support gathering the OpenMetrics text format.
Before I move forward with 1 or 2, I figured I would check to see if extending testutil to support my use-case makes sense to maintainers.
Thanks for the heads up!
I'm in favor of option 3 actually, but we would need to send PRs to prometheus/common first. We'd need a textparser for OpenMetrics, similar to this one, then bump prometheus/common here.
Bumping prometheus/common leads us to another problem: common doesn't work with go1.20 and client Golang promises support for the 3 latest go versions. We would need to wait until go 1.23 is out :/
If you need this solved ASAP, I'd suggest you move forward with making test asserting with the protobuf types, but extending the test utility libraries is definitely a positive thing.
1.23 is scheduled to August, so it might take a while 😬
Thanks! I'll leave this open, and pursue option 2.
prometheus/common with go 1.20 again, there are no blockers for this now