8000 Expose original metric classes via __wrapped__ attribute (#151) · dds/client_python@c2e4bda · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c2e4bda

Browse files
beezzbrian-brazil
authored andcommitted
Expose original metric classes via __wrapped__ attribute (prometheus#151)
Expose original metric classes via __wrapped__ attribute
1 parent 142c685 commit c2e4bda

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

prometheus_client/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ def collect():
556556
registry.register(collector)
557557
return collector
558558

559+
init.__wrapped__ = cls
559560
return init
560561

561562

tests/test_core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ def test_empty_labels_list(self):
307307
h = Histogram('h', 'help', [], registry=self.registry)
308308
self.assertEqual(0, self.registry.get_sample_value('h_sum'))
309309

310+
def test_wrapped_original_class(self):
311+
self.assertEqual(Counter.__wrapped__, Counter('foo', 'bar').__class__)
312+
310313

311314
class TestMetricFamilies(unittest.TestCase):
312315
def setUp(self):
@@ -386,6 +389,7 @@ def test_bad_constructors(self):
386389
self.assertRaises(ValueError, HistogramMetricFamily, 'h', 'help', buckets={}, sum_value=1, labels=['a'])
387390
self.assertRaises(KeyError, HistogramMetricFamily, 'h', 'help', buckets={}, sum_value=1)
388391

392+
389393
class TestCollectorRegistry(unittest.TestCase):
390394
def test_duplicate_metrics_raises(self):
391395
registry = CollectorRegistry()

0 commit comments

Comments
 (0)
0