Skip to content

Commit e0f5dd6

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

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

prometheus_client/metrics_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def add_metric(self, labels, buckets, sum_value, timestamp=None):
220220
if float(buckets[0][0]) >= 0 and sum_value is not None:
221221
# +Inf is last and provides the count value.
222222
self.samples.append(
223-
Sample(self.name + '_count', dict(zip(self._labelnames, labels)), buckets[-1][1], timestamp))
223+
Sample(self.name + '_count', dict(zip(self._labelnames, labels)), buckets[-1][1], timestamp))
224224
self.samples.append(
225225
Sample(self.name + '_sum', dict(zip(self._labelnames, labels)), sum_value, timestamp))
226226

prometheus_client/openmetrics/parser.py

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

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

0 commit comments

Comments
 (0)