Skip to content

feat: implement gauge and counter support for OpenMetrics 2.0#894

Open
dashpole wants to merge 6 commits into
prometheus:mainfrom
dashpole:om2_1
Open

feat: implement gauge and counter support for OpenMetrics 2.0#894
dashpole wants to merge 6 commits into
prometheus:mainfrom
dashpole:om2_1

Conversation

@dashpole

@dashpole dashpole commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Part 1 of #893

Histograms and summaries are left for follow-ups.

Open Questions:

  • How do we indicate that OM 2.0 support is experimental?

@ywwg @bwplotka @krajorama

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For common, given v0 I would just comment on the method. If we want to be fancy we can generate comment in the exposition format too (:

Looks good so far, good start (see comments) - only question is do we iterate on this on main or some feature branch - no strong opinion, assuming commentary is clear.

Thanks

Comment thread expfmt/openmetrics_2_0_create.go
Comment thread expfmt/openmetrics_2_0_create.go
Comment thread expfmt/openmetrics_2_0_create.go
Comment thread expfmt/openmetrics_2_0_create.go
Comment thread expfmt/openmetrics_2_0_create_test.go Outdated
Comment thread expfmt/openmetrics_2_0_create_test.go
@dashpole dashpole marked this pull request as ready for review April 7, 2026 19:09

@ywwg ywwg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me so far. My general opinion is that if some scraper asks for openmetrics 2.0, they should get it... Hypothetically I could see requiring the version number "2.0.0rc" or "1.9.9" just in case?

@dashpole

Copy link
Copy Markdown
Contributor Author

Lots of discussion at the OM wg. We will add a NegotiateIncluding() function that takes a list of supported protocols so we don't end up with NegotiateIncludingOpenMetricsAndOpenMetrics2 ... 😆 . Then the client can decide when it wants to add support, and how it wants to gate it (behind HandlerOpts.EnableOpenMetrics?).

@dashpole

Copy link
Copy Markdown
Contributor Author

I added a NegotiateIncluding function. I didn't deprecate the old functions (e.g. NegotiateIncludingOpenMetrics), but we can do that in a follow-up if we want to.

@dashpole dashpole force-pushed the om2_1 branch 2 times, most recently from 873bb38 to 1bcdef1 Compare May 27, 2026 15:39
@dashpole dashpole requested review from bwplotka and ywwg June 4, 2026 13:21
@bwplotka

Copy link
Copy Markdown
Member

I think that's great, the experimental factor at this level should be a commentary.

As per discussion on Slack I think we decided to follow:

  1. Exposer should eventually switch to OM2 default, but only once ready (which means we recommend opt-in "exposed protocol" option)
  2. Scrapers should be opt-in for now, while OM2 is experimental

Comment thread expfmt/encode.go
@krajorama krajorama self-requested a review June 24, 2026 13:33
Comment thread expfmt/openmetrics_2_0_create_test.go
Comment thread expfmt/openmetrics_2_0_create.go Outdated
Comment thread expfmt/openmetrics_2_0_create_test.go
Comment thread expfmt/openmetrics_2_0_create_test.go Outdated
Comment thread expfmt/encode.go
dashpole added 3 commits July 7, 2026 14:45
Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
…rt timestamps

Signed-off-by: David Ashpole <dashpole@google.com>
@dashpole dashpole force-pushed the om2_1 branch 11 times, most recently from 0f93427 to 5336c49 Compare July 7, 2026 16:32
Signed-off-by: David Ashpole <dashpole@google.com>
@dashpole dashpole force-pushed the om2_1 branch 2 times, most recently from b14d731 to ab106e7 Compare July 7, 2026 16:56
…coders

Signed-off-by: David Ashpole <dashpole@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants