Repository navigation
Conversation
csmarchbanks
approved these changes
Oct 30, 2026
csmarchbanks
left a comment
Member
There was a problem hiding this comment.
Has a conflict now, but generally 👍. Thanks!
Enum(states=['a', 'b', 'a']) exposes e{e="a"} twice in one family. After
state('a') the two samples disagree, 1.0 and 0.0, and the OpenMetrics
parser keeps only the first. Raise at construction, before registration,
as duplicate label names already do.
Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
chrikrah
force-pushed
the
fix/enum-duplicate-states
branch
from
November 2, 2026 18:29
e5cc283 to
6adbad7
Compare
chrikrah
commented
Nov 2, 2026
chrikrah
left a comment
Contributor
Author
There was a problem hiding this comment.
@csmarchbanks rebased onto e2f2bf9; the only conflict was my import collections against the import math that master added on the same line. The change itself is unchanged.
$ python -m pytest tests -q # 6adbad7 on master e2f2bf9, CPython 3.12, tox optional deps installed
454 passed, 32 subtests passed
$ python -m pytest tests/test_core.py -q -k duplicate_states # metrics.py from e2f2bf9, test kept
1 failed, 122 deselected
$ flake8 prometheus_client/ tests/ && isort --check prometheus_client/ tests/ # flake8 7.5.0, isort 5.10.1
It's ready for a merge whenever you have a slot.
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.
Enumaccepts astateslist with a repeated entry and exposes one sample per entry, so the family carries twoe{e="a"}samples. Afterstate('a')they disagree, and the OpenMetrics parser keeps only the first.That breaks the OpenMetrics StateSet rule, "StateSets MUST have one sample per State", and
enum.md, which promises one time series per state. The check sits with the otherEnumargument checks, ahead ofsuper().__init__(), so a rejected metric is never registered, as #1189 arranged for emptystates.Verification
There is no issue for this. #1234 rewrites the same lines of
Enum.__init__to accept an enum class, whose member names cannot repeat, so whichever lands second needs a one-line rebase.@csmarchbanks, this raises for the reason you gave on #1214: a repeated state is almost certainly a typo. A caller who has one today gets a
ValueErrorat construction in place of a contradictory sample. Happy to land it before or after #1234, whichever you merge first.