8000 When labelnames is falsy, pass an empty tuple to __init__ (#147) · sonlinux/client_python@e5e73e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit e5e73e5

Browse files
savoiebrian-brazil
authored andcommitted
When labelnames is falsy, pass an empty tuple to __init__ (prometheus#147)
1 parent 36b5cab commit e5e73e5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

prometheus_client/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def init(name, documentation, labelnames=(), namespace='', subsystem='', registr
536536
raise ValueError('Reserved label metric name: ' + l)
537537
collector = _LabelWrapper(cls, name, labelnames, **kwargs)
538538
else:
539-
collector = cls(name, labelnames, (), **kwargs)
539+
collector = cls(name, (), (), **kwargs)
540540

541541
if not _METRIC_NAME_RE.match(full_name):
542542
raise ValueError('Invalid metric name: ' + full_name)

tests/test_core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ def test_invalid_names_raise(self):
303303
self.assertRaises(ValueError, Counter, 'c', '', labelnames=['__reserved'])
304304
self.assertRaises(ValueError, Summary, 'c', '', labelnames=['quantile'])
305305

306+
def test_empty_labels_list(self):
307+
h = Histogram('h', 'help', [], registry=self.registry)
308+
self.assertEqual(0, self.registry.get_sample_value('h_sum'))
309+
306310

307311
class TestMetricFamilies(unittest.TestCase):
308312
def setUp(self):

0 commit comments

Comments
 (0)
0