Skip to content

[pull] master from prometheus:master - #20

Merged
pull[bot] merged 3 commits into
TheTechOddBug:masterfrom
prometheus:master
Jul 15, 2026
Merged

[pull] master from prometheus:master#20
pull[bot] merged 3 commits into
TheTechOddBug:masterfrom
prometheus:master

Conversation

@pull

@pull pull Bot commented Jul 15, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

sean-kim05 and others added 3 commits July 15, 2026 15:58
Enum.__init__ called super().__init__() -- which registers the collector
in the CollectorRegistry -- before validating that states is non-empty
and that the metric name does not overlap a label name. When either
check failed, the ValueError was raised as expected, but a half-built
Enum (whose _states was never assigned) had already been registered.

That left the registry in a broken state: the name was permanently
taken, so recreating the metric raised 'Duplicated timeseries', and any
subsequent scrape crashed with

    AttributeError: 'Enum' object has no attribute '_states'

when _child_samples iterated self._states. A realistic trigger is
building the states list from configuration that turns out to be empty.

Gauge and Histogram already validate before calling super().__init__();
this moves Enum's two guards ahead of registration to match, so a failed
constructor leaves the registry untouched.

Add test_failed_init_does_not_pollute_registry, which asserts that after
two failed Enum constructions the name is still free, the metric can be
created, and the registry scrapes cleanly.

Signed-off-by: Sean Kim <skim8705@gmail.com>
floatToGoString reproduces Go's strconv.FormatFloat(f, 'g', -1, 64),
which pads a float's exponent to a minimum of two digits. The exponent
was formatted as 'e+0{dot - 1}', which hard-codes a single leading zero
and only produces the right width while dot - 1 is a single digit. Once
the exponent reaches two digits (values >= 1e10, whose repr is still
plain decimal) it over-pads, e.g. 1e10 became '1e+010' instead of Go's
'1e+10'. That affects any emitted sample value or le/quantile bucket
boundary at or above 1e10.

Use '{dot - 1:02d}' so the exponent is zero-padded to a minimum of two
digits and not beyond, matching Go.

Add tests/test_utils.py covering both the previously-correct single-digit
exponents and the two-digit exponents that regressed.

Signed-off-by: Sean Kim <skim8705@gmail.com>
Signed-off-by: prombot <prometheus-team@googlegroups.com>
@pull pull Bot locked and limited conversation to collaborators Jul 15, 2026
@pull pull Bot added the ⤵️ pull label Jul 15, 2026
@pull
pull Bot merged commit 75603d7 into TheTechOddBug:master Jul 15, 2026
0 of 11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

2 participants