Skip to content

Commit 094f18f

Browse files
committed
Change exemplar limit to 128 chars.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
1 parent 2e26e2f commit 094f18f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

prometheus_client/openmetrics/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _parse_remaining_text(text):
359359
exemplar = None
360360
if exemplar_labels is not None:
361361
exemplar_length = sum([len(k) + len(v) for k, v in exemplar_labels.items()])
362-
if exemplar_length > 64:
362+
if exemplar_length > 128:
363363
raise ValueError("Exmplar labels are too long: " + text)
364364
exemplar = Exemplar(
365365
exemplar_labels,

tests/openmetrics/test_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ def test_histogram_exemplars(self):
152152
# HELP a help
153153
a_bucket{le="1.0"} 0 # {a="b"} 0.5
154154
a_bucket{le="2.0"} 2 # {a="c"} 0.5
155-
a_bucket{le="+Inf"} 3 # {a="1234567890123456789012345678901234567890123456789012345678"} 4 123
155+
a_bucket{le="+Inf"} 3 # {a="2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"} 4 123
156156
# EOF
157157
""")
158158
hfm = HistogramMetricFamily("a", "help")
159159
hfm.add_sample("a_bucket", {"le": "1.0"}, 0.0, None, Exemplar({"a": "b"}, 0.5))
160160
hfm.add_sample("a_bucket", {"le": "2.0"}, 2.0, None, Exemplar({"a": "c"}, 0.5)),
161161
hfm.add_sample("a_bucket", {"le": "+Inf"}, 3.0, None,
162-
Exemplar({"a": "1234567890123456789012345678901234567890123456789012345678"}, 4,
162+
Exemplar({"a": "2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"}, 4,
163163
Timestamp(123, 0)))
164164
self.assertEqual([hfm], list(families))
165165

@@ -693,7 +693,7 @@ def test_invalid_input(self):
693693
('# TYPE a histogram\na_bucket{le="+Inf"} 1 # {} 1 \n# EOF\n'),
694694
('# TYPE a histogram\na_bucket{le="+Inf"} 1 # {} 1 1 \n# EOF\n'),
695695
('# TYPE a histogram\na_bucket{le="+Inf"} 1 # '
696-
'{a="2345678901234567890123456789012345678901234567890123456789012345"} 1 1\n# EOF\n'),
696+
'{a="23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"} 1 1\n# EOF\n'),
697697
('# TYPE a histogram\na_bucket{le="+Inf"} 1 # {} 0x1p-3\n# EOF\n'),
698698
('# TYPE a histogram\na_bucket{le="+Inf"} 1 # {} 1 0x1p-3\n# EOF\n'),
699699
# Exemplars on unallowed samples.

0 commit comments

Comments
 (0)