Skip to content

feat: Add OpenMetrics2 configuration support - #1939

Merged
jaydeluca merged 4 commits into
mainfrom
openmetrics2-part1
Mar 12, 2026
Merged

feat: Add OpenMetrics2 configuration support#1939
jaydeluca merged 4 commits into
mainfrom
openmetrics2-part1

Conversation

@jaydeluca

@jaydeluca jaydeluca commented Mar 6, 2026

Copy link
Copy Markdown
Member

Part of #1912

BEGIN_COMMIT_OVERRIDE
chore: Add OpenMetrics2 configuration support
END_COMMIT_OVERRIDE

Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds experimental OpenMetrics 2.0 configuration plumbing to the prometheus-metrics-config module so OM2 feature flags can be set via builder APIs and loaded from properties/env vars (as part of #1912).

Changes:

  • Introduce OpenMetrics2Properties with OM2 feature-flag fields, builder, and property loading.
  • Wire OM2 properties into PrometheusProperties and PrometheusPropertiesLoader.
  • Add/extend unit tests covering defaults, builder usage, enable-all, and property loading/error handling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesLoader.java Loads OpenMetrics2Properties and includes it in the assembled PrometheusProperties.
prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusProperties.java Adds openMetrics2Properties field + getter and builder APIs (enableOpenMetrics2, direct assignment).
prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/OpenMetrics2Properties.java New OM2 flag container with property parsing and builder (including enableAll()).
prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesTest.java Adds tests for OM2 builder patterns, defaults, and loading via PrometheusPropertiesLoader.
prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/OpenMetrics2PropertiesTest.java New tests for OM2 property loading, invalid values, builder behavior, and defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zeitlinger zeitlinger 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.

Nice clean PR — follows existing patterns well and the test coverage is thorough.

A few things to consider:


Property prefix: open_metrics2 vs openmetrics2

The existing OTel prefix uses opentelemetry (no separator). open_metrics2 with the underscore looks a bit odd next to it. openmetrics2 would be more consistent — worth a conscious decision since this becomes a public property key.


Consider marking the API as experimental

Since the OM2 spec is still draft, it might be worth adding a Javadoc note like @apiNote Experimental — subject to change on OpenMetrics2Properties and getOpenMetrics2Properties() so users know the API may change.


Suffix validation interaction

Opened #1941 to discuss how disableSuffixAppending interacts with _total suffix validation/stripping in PrometheusNaming and Counter.Builder.

@jaydeluca

Copy link
Copy Markdown
Member Author

Property prefix: open_metrics2 vs openmetrics2
The existing OTel prefix uses opentelemetry (no separator). open_metrics2 with the underscore looks a bit odd next to it. openmetrics2 would be more consistent — worth a conscious decision since this becomes a public property key.

Sure, openmetrics2 does look better IMO, should we go with that?

Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>

@zeitlinger zeitlinger 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.

LGTM — clean flag infrastructure, good test coverage, follows existing patterns.

Two nits (not blocking):

  1. Consider adding @apiNote Experimental — subject to change on OpenMetrics2Properties and getOpenMetrics2Properties() for IDE visibility (the class Javadoc mentions it but @apiNote renders more prominently).

  2. I'll update #1912 to reflect that disableSuffixAppending is handled separately via #1941 (scrape-time suffix handling) rather than as an OM2 config flag.

Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
@jaydeluca
jaydeluca force-pushed the openmetrics2-part1 branch from fc4026a to 84fe8c4 Compare March 12, 2026 11:34
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
@jaydeluca

jaydeluca commented Mar 12, 2026

Copy link
Copy Markdown
Member Author

we don't use @apiNote anywhere else in this project, and the build doesn't like it:

[javadoc] [ERROR] /home/runner/work/client_java/client_java/prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/OpenMetrics2Properties.java:8: error: unknown tag. Unregistered custom tag?
[javadoc] [ERROR] * @apiNote These properties are experimental and subject to change.
[javadoc] [ERROR] ^

@jaydeluca
jaydeluca enabled auto-merge (squash) March 12, 2026 11:40
@jaydeluca
jaydeluca merged commit d9d8dab into main Mar 12, 2026
9 checks passed
@jaydeluca
jaydeluca deleted the openmetrics2-part1 branch March 12, 2026 11:46
This was referenced Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants