8000 Reduce MUST canonical numbers to +Inf, per OM discussions. · Global-localhost/client_python@1ef8272 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ef8272

Browse files
committed
Reduce MUST canonical numbers to +Inf, per OM discussions.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
1 parent e0f5dd6 commit 1ef8272

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

prometheus_client/openmetrics/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def text_string_to_metric_families(text):
2525
yield metric_family
2626

2727

28-
_CANONICAL_NUMBERS = set([i / 1000.0 for i in range(10000)] + [10.0**i for i in range(-10, 11)] + [float("inf")])
28+
_CANONICAL_NUMBERS = set([float("inf")])
2929

3030

3131
def _isUncanonicalNumber(s):

tests/openmetrics/test_parser.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ def test_summary_quantiles(self):
102102
a_count 1
103103
a_sum 2
104104
a{quantile="0.5"} 0.7
105+
a{quantile="1"} 0.8
105106
# EOF
106107
""")
107108
# The Python client doesn't support quantiles, but we
108109
# still need to be able to parse them.
109110
metric_family = SummaryMetricFamily("a", "help", count_value=1, sum_value=2)
110111
metric_family.add_sample("a", {"quantile": "0.5"}, 0.7)
112+
metric_family.add_sample("a", {"quantile": "1"}, 0.8)
111113
self.assertEqual([metric_family], list(families))
112114

113115
def test_simple_histogram(self):
@@ -125,9 +127,16 @@ def test_simple_histogram(self):
125127
def test_histogram_noncanonical(self):
126128
families = text_string_to_metric_families("""# TYPE a histogram
127129
# HELP a help
130+
a_bucket{le="0"} 0
128131
a_bucket{le="0.00000000001"} 0
132+
a_bucket{le="0.0000000001"} 0
133+
a_bucket{le="1e-04"} 0
129134
a_bucket{le="1.1e-4"} 0
130135
a_bucket{le="1.1e-3"} 0
136+
a_bucket{le="1.1e-2"} 0
137+
a_bucket{le="1"} 0
138+
a_bucket{le="1e+05"} 0
139+
a_bucket{le="10000000000"} 0
131140
a_bucket{le="100000000000.0"} 0
132141
a_bucket{le="+Inf"} 3
133142
a_count 3
@@ -717,7 +726,6 @@ def test_invalid_input(self):
717726
('# TYPE a summary\na{quantile="foo"} 0\n# EOF\n'),
718727
('# TYPE a summary\na{quantile="1.01"} 0\n# EOF\n'),
719728
('# TYPE a summary\na{quantile="NaN"} 0\n# EOF\n'),
720-
('# TYPE a summary\na{quantile="1"} 0\n# EOF\n'),
721729
('# TYPE a histogram\na_bucket 0\n# EOF\n'),
722730
('# TYPE a gaugehistogram\na_bucket 0\n# EOF\n'),
723731
('# TYPE a stateset\na 0\n# EOF\n'),
@@ -751,13 +759,6 @@ def test_invalid_input(self):
751759
('# TYPE a gaugehistogram\na_bucket{le="+Inf"} 0\na_gcount 0\n# EOF\n'),
752760
('# TYPE a histogram\na_count 1\na_bucket{le="+Inf"} 0\n# EOF\n'),
753761
('# TYPE a histogram\na_bucket{le="+Inf"} 0\na_count 1\n# EOF\n'),
754-
('# TYPE a histogram\na_bucket{le="0"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
755-
('# TYPE a histogram\na_bucket{le="1"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
756-
('# TYPE a histogram\na_bucket{le="0.0000000001"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
757-
('# TYPE a histogram\na_bucket{le="1.1e-2"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
758-
('# TYPE a histogram\na_bucket{le="1e-04"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
759-
('# TYPE a histogram\na_bucket{le="1e+05"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
760-
('# TYPE a histogram\na_bucket{le="10000000000"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
761762
('# TYPE a histogram\na_bucket{le="+INF"} 0\n# EOF\n'),
762763
('# TYPE a histogram\na_bucket{le="2"} 0\na_bucket{le="1"} 0\na_bucket{le="+Inf"} 0\n# EOF\n'),
763764
('# TYPE a histogram\na_bucket{le="1"} 1\na_bucket{le="2"} 1\na_bucket{le="+Inf"} 0\n# EOF\n'),

0 commit comments

Comments
 (0)
0