diff --git a/README.md b/README.md index 001fb125..ca0b3fda 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,15 @@ c.inc(1.6) # Increment by given value There are utilities to count exceptions raised: ```python -@c.countExceptions() +@c.count_exceptions() def f(): pass -with c.countExceptions(): +with c.count_exceptions(): pass # Count only one type of exception -with c.countExceptions(ValueError): +with c.count_exceptions(ValueError): pass ``` @@ -60,14 +60,14 @@ g.set(4.2) # Set to a given value There are utilities for common use cases: ```python -g.setToCurrentTime() # Set to current unixtime +g.set_to_current_time() # Set to current unixtime # Increment when entered, decrement when exited. -@g.trackInprogress() +@g.track_inprogress() def f(): pass -with g.trackInprogress(): +with g.track_inprogress(): pass ``` diff --git a/prometheus_client/__init__.py b/prometheus_client/__init__.py index 7bccdcc1..e100b274 100644 --- a/prometheus_client/__init__.py +++ b/prometheus_client/__init__.py @@ -170,7 +170,7 @@ def inc(self, amount=1): with self._lock: self._value += amount - def countExceptions(self, exception=Exception): + def count_exceptions(self, exception=Exception): '''Count exceptions in a block of code or function. Can be used as a function decorator or context manager. @@ -218,11 +218,11 @@ def set(self, value): with self._lock: self._value = float(value) - def setToCurrentTime(self, value): + def set_to_current_time(self): '''Set gauge to the current unixtime.''' self.set(time.time()) - def trackInprogress(self): + def track_inprogress(self): '''Track inprogress blocks of code or functions. Can be used as a function decorator or context manager. diff --git a/setup.py b/setup.py index cc1fa8c9..52ebe2bd 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def read(fname): setup( name = "prometheus_client", - version = "0.0.4", + version = "0.0.5", author = "Brian Brazil", author_email = "brian.brazil@gmail.com", description = ("Python client for the Prometheus monitoring system."), diff --git a/tests/test_client.py b/tests/test_client.py index f0c525e2..2eae2725 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -19,7 +19,7 @@ def test_negative_increment_raises(self): self.assertRaises(ValueError, self.counter.inc, -1) def test_function_decorator(self): - @self.counter.countExceptions(ValueError) + @self.counter.count_exceptions(ValueError) def f(r): if r: raise ValueError @@ -37,12 +37,12 @@ def f(r): self.assertEquals(1, self.registry.get_sample_value('c')) def test_block_decorator(self): - with self.counter.countExceptions(): + with self.counter.count_exceptions(): pass self.assertEquals(0, self.registry.get_sample_value('c')) raised = False try: - with self.counter.countExceptions(): + with self.counter.count_exceptions(): raise ValueError except: raised = True @@ -65,7 +65,7 @@ def test_gauge(self): def test_function_decorator(self): self.assertEquals(0, self.registry.get_sample_value('g')) - @self.gauge.trackInprogress() + @self.gauge.track_inprogress() def f(): self.assertEquals(1, self.registry.get_sample_value('g')) f() @@ -73,7 +73,7 @@ def f(): def test_block_decorator(self): self.assertEquals(0, self.registry.get_sample_value('g')) - with self.gauge.trackInprogress(): + with self.gauge.track_inprogress(): self.assertEquals(1, self.registry.get_sample_value('g')) self.assertEquals(0, self.registry.get_sample_value('g'))