Skip to content

Conversation

@vesari
Copy link
Contributor

@vesari vesari commented Jan 27, 2026

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 .

…nge tests accordingly

Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM, just minor nit for tests.

{
metric: metric1,
format: FmtOpenMetrics_1_0_0,
format: FmtOpenMetrics_0_0_1,
Copy link
Member

Choose a reason for hiding this comment

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

copy pasta?

// 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 {
Copy link
Member

Choose a reason for hiding this comment

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

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 bwplotka self-requested a review February 9, 2026 13:44
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.

2 participants