Skip to content

Commit 64fac0f

Browse files
committed
Simplify label boundary detection in sample parser
Signed-off-by: afrkorsakow <afrkorsakow@gmail.com>
1 parent c0e416d commit 64fac0f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

prometheus_client/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def _parse_value(value):
244244
def _parse_sample(text):
245245
separator = " # "
246246
# Detect the labels in the text
247-
label_start = _next_unquoted_char(text, '{')
247+
label_start = text.find('{')
248248
if label_start == -1 or separator in text[:label_start]:
249249
# We don't have labels, but there could be an exemplar.
250250
name_end = _next_unquoted_char(text, ' \t')
@@ -256,7 +256,7 @@ def _parse_sample(text):
256256
value, timestamp = _parse_value_and_timestamp(remaining_text)
257257
return Sample(name, {}, value, timestamp)
258258
name = text[:label_start].strip()
259-
label_end = _next_unquoted_char(text[label_start:], '}') + label_start
259+
label_end = text.rfind('}')
260260
labels = parse_labels(text[label_start + 1:label_end], False)
261261
if not name:
262262
# Name might be in the labels

0 commit comments

Comments
 (0)