Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

om2: MetricFamilyName is MetricName#2791

Open
bwplotka wants to merge 2 commits intomain from
bwplotka/om2-restr
Open

om2: MetricFamilyName is MetricName #2791
bwplotka wants to merge 2 commits intomain from
bwplotka/om2-restr

Conversation

@bwplotka
Copy link
Member

@bwplotka bwplotka commented Dec 3, 2025
edited
Loading

Fixes prometheus/OpenMetrics#305

(削除) We can either merge this with TODOs before complex values/types or wait for complex type/values. (削除ここまで)

Copy link
Member Author

bwplotka commented Dec 3, 2025
edited
Loading

I am bit surprised but I couldn't find any special rule for those suffixes in the ABNF to change... also tests passes despite me adding suffixes to MF names. Something smells like ABNF is too relaxed.

Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

I could review only half of the PR 😬, I have some small comments

@jan--f jan--f added the kind/feature New documentation content label Dec 5, 2025
Copy link
Member

ywwg commented Feb 9, 2026

do we still intend to merge this?

@bwplotka bwplotka force-pushed the bwplotka/om2-restr branch 6 times, most recently from 11a31fa to ff36b8d Compare February 10, 2026 06:41
Copy link
Member Author

I think so. Much simpler now with Composite Types merged in.

Copy link
Member Author


* [Histogram](#histogram) MetricFamily Type.
* [GaugeHistogram](#gauge-histogram) MetricFamily Type.
* [GaugeHistogram](#gaugehistogram) MetricFamily Type.
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI: Broken link

or dropped data.

The name of a MetricFamily MUST NOT result in a potential clash for sample metric names as per the ABNF with another MetricFamily in the Text Format within a MetricSet. An example would be a gauge called "foo_total" as a counter called "foo" could create a "foo_total" in the text format.
Exposers MUST avoid names that could conflict with the Text OpenMetrics 1.0 [histogram](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec.md#histogram-1), [gaugehistogram](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec.md#gaugehistogram-1) and [summary](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec.md#summary-1) suffixes.
Copy link
Member Author

@bwplotka bwplotka Feb 10, 2026
edited
Loading

Choose a reason for hiding this comment

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

Another way to put it is that gauges, counters, stateset names MUST NOT end with _count, _sum, _gcount, _gsum, _bucket - kind of simple rule. Would that be more clear?

Copy link
Member

@krajorama krajorama Feb 10, 2026

Choose a reason for hiding this comment

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

I'd just simplify further:

MetricFamily name MUST NOT end with _count, _sum, _gcount, _gsum, _bucket.

It's true for anything except Histograms and Gauge Histograms , including Summary since that has series without magic suffixes. But I don't think it's worth making an exception for Histograms, Gauge Histograms. Especially because I don't think people will actually follow this unless SDKs prohibit it and I think we need to add a line about ingestors:

Ingestors MAY accept non compliant MetricFamily names and only error out when a naming clash occurs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally good point, but especially _count might be common as a standalone gauge or even counter. This line would prohibit for compatibility reason (so tmp time) and actually is not needed if the same target does NOT expose <metric without _count_but_histogram>.

Ingestors MAY accept non compliant MetricFamily names and only error out when a naming clash occurs.

Again, if this needs to be stronger that we need to move MetricFamily name MUST NOT end with _count, _sum, _gcount, _gsum, _bucket. to SHOULD NOT.

Every "must" MAY be accepted by some implementations, no?

I proposed SHOULD NOT for wide rule, and MUST NOT for collision explanation - framed as "OpenMetrics 2 converted to OpenMetrics 1 or Prom TEXT should not cause collisions)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I agree with SHOULD NOT. MUST NOT presumably means that we place more of a burden on clients exposing the metrics to ensure it doesn't happen (like suffixes in OM 1.0). We either would fail scrapes with bad suffixes, or we would have to "fix" names by modifying them to make them valid (which we sometimes did for OM 1.0).

or dropped data.

The name of a MetricFamily MUST NOT result in a potential clash for sample metric names as per the ABNF with another MetricFamily in the Text Format within a MetricSet. An example would be a gauge called "foo_total" as a counter called "foo" could create a "foo_total" in the text format.
Exposers MUST avoid names that could conflict with the Text OpenMetrics 1.0 [histogram](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec.md#histogram-1), [gaugehistogram](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec.md#gaugehistogram-1) and [summary](https://github.com/prometheus/docs/blob/main/docs/specs/om/open_metrics_spec.md#summary-1) suffixes.
Copy link
Member

@krajorama krajorama Feb 10, 2026

Choose a reason for hiding this comment

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

I'd just simplify further:

MetricFamily name MUST NOT end with _count, _sum, _gcount, _gsum, _bucket.

It's true for anything except Histograms and Gauge Histograms , including Summary since that has series without magic suffixes. But I don't think it's worth making an exception for Histograms, Gauge Histograms. Especially because I don't think people will actually follow this unless SDKs prohibit it and I think we need to add a line about ingestors:

Ingestors MAY accept non compliant MetricFamily names and only error out when a naming clash occurs.

Fixes prometheus/OpenMetrics#305
Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: bwplotka <bwplotka@gmail.com>
###### Reserved Suffixes

The name of a MetricFamily MUST NOT result in a potential clash for sample metric names as per the ABNF with another MetricFamily in the Text Format within a MetricSet. An example would be a gauge called "foo_total" as a counter called "foo" could create a "foo_total" in the text format.
MetricFamily name SHOULD NOT end with `_count`, `_sum`, `_gcount`, `_gsum`, `_bucket`. Specifically a name MUST NOT create a MetricName collision when converted to [the Text OpenMetrics 1.0](https://prometheus.io/docs/specs/om/open_metrics_spec).
Copy link
Member Author

Choose a reason for hiding this comment

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

From WG:

  • Let's have other guidance for naming conventions (snake_case, unit) (TODO)
Suggested change
MetricFamily name SHOULD NOT end with `_count`, `_sum`, `_gcount`, `_gsum`, `_bucket`. Specifically a name MUST NOT create a MetricName collision when converted to [the Text OpenMetrics 1.0](https://prometheus.io/docs/specs/om/open_metrics_spec).
MetricFamily a name MUST NOT create a MetricName collision when converted to [the Text OpenMetrics 1.0](https://prometheus.io/docs/specs/om/open_metrics_spec). This can happen for MetricFamily names with `_count`, `_sum`, `_gcount`, `_gsum`, `_bucket`.
  • What if exposer has this metric, what should be done? We need consistent logic for violating MUST NOT. Implementations are used to be relaxing. TODO research failure modes for violating various MUST NOT rules? e.g. server side will reject this. We don't want to put burden on clients. SDK blocking.
  • General usability generic protocol vs e2e Prometheus experience?
  • Collision move to should not and be around naming?
  • Stronger case than just naming suffix.
  • leaning into "SHOULD NOT and explain ingestors/Prometheus will likely reject such scrape for foreseeable future (for this case)"

Copy link
Member

@krajorama krajorama Feb 16, 2026

Choose a reason for hiding this comment

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

Assuming SHOULD NOT for the suffixes

MUST NOT conflict

To ensure that the user doesn't run into this, the SDK must validate. We don't do this now, so introducing the check is technically breaking (you can register foo_total gauge and foo counter).

SDKs already check for some collisions (go, java.

But not specifically for this. So I think it's not that hard to implement on top of existing checks !?

It might force a major version, as this can be technically breaking, but on the other hand, I think we'll need a major version anyway to be able to introduce some strict mode that checks that Prometheus naming conventions are followed. SDK strict mode should be the default and I think it should be possible to turn it off generally or per metric.

Even with this validation, the user might run into problems later due to federation or some other feature.

SHOULD NOT conflict

As you say, we can explain why it's bad, but no burden on anyone, the ingestor will just reject the sample if it runs into it. This is simpler. It would be super annoying if we rejected the whole scrape due to one metric.

Conclusion

I think to avoid breaking change due to OM2.0 I'd also say SHOULD NOT.

But I'll continue to advocate for SDKs with default strict mode that checks that the name specified follows Prometheus naming conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ywwg ywwg ywwg left review comments

@krajorama krajorama krajorama left review comments

@ArthurSens ArthurSens ArthurSens left review comments

@dashpole dashpole dashpole left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

kind/feature New documentation content

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

OM 2.0: Restrict metric family to NOT strip suffix

AltStyle によって変換されたページ (->オリジナル) /