8000 Expose original metric classes via __wrapped__ attribute by beezz · Pull Request #151 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

Expose original metric classes via __wrapped__ attribute #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prometheus_client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ def collect():
registry.register(collector)
return collector

init.__wrapped__ = cls
return init


Expand Down
4 changes: 4 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ def test_empty_labels_list(self):
h = Histogram('h', 'help', [], registry=self.registry)
self.assertEqual(0, self.registry.get_sample_value('h_sum'))

def test_wrapped_original_class(self):
self.assertEqual(Counter.__wrapped__, Counter('foo', 'bar').__class__)


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


class TestCollectorRegistry(unittest.TestCase):
def test_duplicate_metrics_raises(self):
registry = CollectorRegistry()
Expand Down
0