client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

Consider support for testing exemplars in prometheus/testutil

Open dashpole opened this issue 1 year ago • 5 comments

Context: https://github.com/open-telemetry/opentelemetry-go/pull/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:

  1. Re-implement GatherAndCompare in my own tests, and make it use OpenMetrics text format, instead of the Prometheus text format.
  2. Write unit test assertions on the go-protobuf types from prometheus.Metric.Write() to check for exemplars separately.
  3. 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.

dashpole avatar Mar 27 '24 14:03 dashpole

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 :/

ArthurSens avatar Mar 27 '24 18:03 ArthurSens

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 😬

ArthurSens avatar Mar 27 '24 18:03 ArthurSens

Thanks! I'll leave this open, and pursue option 2.

dashpole avatar Mar 27 '24 18:03 dashpole

prometheus/common with go 1.20 again, there are no blockers for this now

ArthurSens avatar May 13 '24 21:05 ArthurSens

Hello 👋 Looks like there was no activity on this issue for the last 3 months. Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗 If there will be no activity in the next 4 weeks, this issue will be closed (we can always reopen an issue if we need!).

stale[bot] avatar Jul 19 '25 06:07 stale[bot]