Skip to content

Commit 4a53b82

Browse files
authored
Merge pull request #19 from faucetsdn/v0.22.1
Upgrade python3-prometheus-client to v0.22.1
2 parents 909f137 + 46a9601 commit 4a53b82

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

debian/patches/0002-Update-pyproject.toml.patch

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@ Index: python3-prometheus-client/pyproject.toml
22
===================================================================
33
--- python3-prometheus-client.orig/pyproject.toml
44
+++ python3-prometheus-client/pyproject.toml
5-
@@ -47,3 +47,17 @@ Documentation = "https://prometheus.gith
5+
@@ -7,11 +7,7 @@ name = "prometheus_client"
6+
version = "0.22.1"
7+
description = "Python client for the Prometheus monitoring system."
8+
readme = "README.md"
9+
-license = "Apache-2.0 AND BSD-2-Clause"
10+
-license-files = [
11+
- "LICENSE",
12+
- "NOTICE",
13+
-]
14+
+license = { file = "LICENSE" }
15+
requires-python = ">=3.9"
16+
authors = [
17+
{ name = "The Prometheus Authors", email = "[email protected]" },
18+
@@ -50,3 +46,17 @@ Documentation = "https://prometheus.gith
619

720
[tool.setuptools.package-data]
821
prometheus_client = ['py.typed']

prometheus_client/parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ def build_metric(name: str, documentation: str, typ: str, samples: List[Sample])
308308
continue
309309
candidate_name, quoted = '', False
310310
if len(parts) > 2:
311+
# Ignore comment tokens
312+
if parts[1] != 'TYPE' and parts[1] != 'HELP':
313+
continue
311314
candidate_name, quoted = _unquote_unescape(parts[2])
312315
if not quoted and not _is_valid_legacy_metric_name(candidate_name):
313316
raise ValueError
@@ -342,9 +345,6 @@ def build_metric(name: str, documentation: str, typ: str, samples: List[Sample])
342345
'histogram': ['_count', '_sum', '_bucket'],
343346
}.get(typ, [''])
344347
allowed_names = [name + n for n in allowed_names]
345-
else:
346-
# Ignore other comment tokens
347-
pass
348348
elif line == '':
349349
# Ignore blank lines
350350
pass

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
[build-system]
2-
requires = ["setuptools"]
2+
requires = ["setuptools>=77.0.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "prometheus_client"
7-
version = "0.22.0"
7+
version = "0.22.1"
88
description = "Python client for the Prometheus monitoring system."
99
readme = "README.md"
10-
license = { file = "LICENSE" }
10+
license = "Apache-2.0 AND BSD-2-Clause"
11+
license-files = [
12+
"LICENSE",
13+
"NOTICE",
14+
]
1115
requires-python = ">=3.9"
1216
authors = [
1317
{ name = "The Prometheus Authors", email = "[email protected]" },
@@ -33,7 +37,6 @@ classifiers = [
3337
"Programming Language :: Python :: Implementation :: CPython",
3438
"Programming Language :: Python :: Implementation :: PyPy",
3539
"Topic :: System :: Monitoring",
36-
"License :: OSI Approved :: Apache Software License",
3740
]
3841

3942
[project.optional-dependencies]

tests/test_parser.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ def test_blank_lines_and_comments(self):
120120
""")
121121
self.assertEqualMetrics([CounterMetricFamily("a", "help", value=1)], list(families))
122122

123+
124+
def test_comments_parts_are_not_validated_against_legacy_metric_name(self):
125+
# https://github.com/prometheus/client_python/issues/1108
126+
families = text_string_to_metric_families("""
127+
# A simple. comment line where third token cannot be matched against METRIC_NAME_RE under validation.py
128+
# 3565 12345/4436467 another random comment line where third token cannot be matched against METRIC_NAME_RE under validation.py
129+
""")
130+
self.assertEqualMetrics([], list(families))
131+
132+
133+
123134
def test_tabs(self):
124135
families = text_string_to_metric_families("""#\tTYPE\ta\tcounter
125136
#\tHELP\ta\thelp

0 commit comments

Comments
 (0)