Repository navigation
feat: preserve metric suffixes in OpenMetrics 2.0 - #2529
Open
arnabnandy7 wants to merge 2 commits into
Open
arnabnandy7 wants to merge 2 commits into
arnabnandy7 wants to merge 2 commits into
Conversation
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
arnabnandy7
requested review from
dhoard,
fstab,
jaydeluca and
zeitlinger
as code owners
October 7, 2026 09:48
Member
|
Let's discuss the feature in #2518 first. |
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Contributor
|
Contributor
Author
@zeitlinger sure thanks, I'll post in issue for further discussion. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an OpenMetrics 2.0 naming option that preserves the suffix behavior of OpenMetrics 1.0 by default.
io.prometheus.openmetrics2.suffixes.suffixestotrue._totalfor counters.suffixes=false.Fixes #2518.
Why
Previously, enabling the OpenMetrics 2.0 writer exposed names exactly as passed to metric builders. For common instrumentation such as:
OpenMetrics 1.0 exposed
requests_bytes_total, while OpenMetrics 2.0 exposedrequests.Changing the negotiated format could therefore create new series and silently break existing queries, alerts, recording rules, and dashboards.
With this change, the OpenMetrics 2.0 writer exposes
requests_bytes_totalby default. Users who need suffix-free or OpenTelemetry-style names can opt out:io.prometheus.openmetrics2.suffixes=falseImplementation
The writer reuses
MetricMetadata.expositionBaseName, which already contains the normalized unit suffix and preserves explicitly provided suffixes. Counter names then receive_totalonly when it is missing.The existing OpenMetrics 1.0 summary-writing flow is reused with the selected metric name so summary metadata and samples follow the same configuration.
Validation
Ran targeted tests for the affected modules:
Command:
./mvnw test \ -pl prometheus-metrics-config,prometheus-metrics-exposition-textformats,prometheus-metrics-core \ -am \ -Dtest=OpenMetrics2PropertiesTest,PrometheusPropertiesTest,OpenMetrics2TextFormatWriterTest \ -Dcoverage.skip=true \ -Dsurefire.failIfNoSpecifiedTests=false