Remove logic adding unit to metrics name#877
Open
vesari wants to merge 3 commits intoprometheus:mainfrom
Open
Conversation
…nge tests accordingly Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
bwplotka
approved these changes
Feb 9, 2026
Member
bwplotka
left a comment
There was a problem hiding this comment.
LGTM, just minor nit for tests.
expfmt/encode_test.go
Outdated
| { | ||
| metric: metric1, | ||
| format: FmtOpenMetrics_1_0_0, | ||
| format: FmtOpenMetrics_0_0_1, |
| // Without opting in this way, the unit will not be added to the metric name and, | ||
| // on top of that, the unit will not be passed onto the output, even if it | ||
| // were declared in the *dto.MetricFamily struct, i.e. even if in.Unit !=nil. | ||
| func WithUnit() EncoderOption { |
Member
There was a problem hiding this comment.
The only potential question is around compatibility for this. For client_golang we should be fine, we don't surface this option to users.
But for potentially downstream common users this might be explictly breaking (compile error). I don't know about any evidences of wide usage, also it could be a damaging option (renaming metrics), so I vote we kill it.
bwplotka
approved these changes
Feb 9, 2026
Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
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.
Following this discussion regarding OM unit support in client_golang, this PR removes the optional unit flag and the related logic that would automatically change the metric name if the UNIT field was populated but the unit not already included in the metric name. This is needed to complete the afore mentioned client_golang PR. cc @bwplotka .