8000 Simplify code a bit · parsaeian/client_python@f4c08cd · GitHub
[go: up one dir, main page]

Skip to content

Commit f4c08cd

Browse files
committed
Simplify code a bit
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
1 parent a61233d commit f4c08cd

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

prometheus_client/openmetrics/parser.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,7 @@ def text_fd_to_metric_families(fd):
294294
295295
Yields core.Metric's.
296296
"""
297-
name = ''
298-
documentation = None
299-
typ = None
300-
unit = None
301-
group = None
302-
seen_groups = set()
303-
group_timestamp = None
304-
samples = []
297+
name = None
305298
allowed_names = []
306299
eof = False
307300

@@ -344,7 +337,7 @@ def build_metric(name, documentation, typ, unit, samples):
344337
if parts[2] == name and samples:
345338
raise ValueError("Received metadata after samples: " + line)
346339
if parts[2] != name:
347-
if name != '':
340+
if name is not None:
348341
yield build_metric(name, documentation, typ, unit, samples)
349342
# New metric
350343
name = parts[2]
@@ -387,7 +380,7 @@ def build_metric(name, documentation, typ, unit, samples):
387380
else:
388381
sample = _parse_sample(line)
389382
if sample.name not in allowed_names:
390-
if name != '':
383+
if name is not None:
391384
yield build_metric(name, documentation, typ, unit, samples)
392385
# Start an unknown metric.
393386
name = sample.name
@@ -434,7 +427,7 @@ def build_metric(name, documentation, typ, unit, samples):
434427
and sample.name.endswith('_bucket')):
435428
raise ValueError("Invalid line only histogram/gaugehistogram buckets can have exemplars: " + line)
436429

437-
if name != '':
430+
if name is not None:
438431
yield build_metric(name, documentation, typ, unit, samples)
439432

440433
if not eof:

0 commit comments

Comments
 (0)
0