Skip to content

Commit b0a6c81

Browse files
committed
Merge pull request prometheus#3 from brian-brazil/master
Use snake case for method names.
2 parents 8a58c95 + 789c0d4 commit b0a6c81

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ c.inc(1.6) # Increment by given value
3232
There are utilities to count exceptions raised:
3333

3434
```python
35-
@c.countExceptions()
35+
@c.count_exceptions()
3636
def f():
3737
pass
3838

39-
with c.countExceptions():
39+
with c.count_exceptions():
4040
pass
4141

4242
# Count only one type of exception
43-
with c.countExceptions(ValueError):
43+
with c.count_exceptions(ValueError):
4444
pass
4545
```
4646

@@ -60,14 +60,14 @@ g.set(4.2) # Set to a given value
6060
There are utilities for common use cases:
6161

6262
```python
63-
g.setToCurrentTime() # Set to current unixtime
63+
g.set_to_current_time() # Set to current unixtime
6464

6565
# Increment when entered, decrement when exited.
66-
@g.trackInprogress()
66+
@g.track_inprogress()
6767
def f():
6868
pass
6969

70-
with g.trackInprogress():
70+
with g.track_inprogress():
7171
pass
7272
```
7373

prometheus_client/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def inc(self, amount=1):
170170
with self._lock:
171171
self._value += amount
172172

173-
def countExceptions(self, exception=Exception):
173+
def count_exceptions(self, exception=Exception):
174174
'''Count exceptions in a block of code or function.
175175
176176
Can be used as a function decorator or context manager.
@@ -218,11 +218,11 @@ def set(self, value):
218218
with self._lock:
219219
self._value = float(value)
220220

221-
def setToCurrentTime(self, value):
221+
def set_to_current_time(self):
222222
'''Set gauge to the current unixtime.'''
223223
self.set(time.time())
224224

225-
def trackInprogress(self):
225+
def track_inprogress(self):
226226
'''Track inprogress blocks of code or functions.
227227
228228
Can be used as a function decorator or context manager.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def read(fname):
1010

1111
setup(
1212
name = "prometheus_client",
13-
version = "0.0.4",
13+
version = "0.0.5",
1414
author = "Brian Brazil",
1515
author_email = "brian.brazil@gmail.com",
1616
description = ("Python client for the Prometheus monitoring system."),

tests/test_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_negative_increment_raises(self):
1919
self.assertRaises(ValueError, self.counter.inc, -1)
2020

2121
def test_function_decorator(self):
22-
@self.counter.countExceptions(ValueError)
22+
@self.counter.count_exceptions(ValueError)
2323
def f(r):
2424
if r:
2525
raise ValueError
@@ -37,12 +37,12 @@ def f(r):
3737
self.assertEquals(1, self.registry.get_sample_value('c'))
3838

3939
def test_block_decorator(self):
40-
with self.counter.countExceptions():
40+
with self.counter.count_exceptions():
4141
pass
4242
self.assertEquals(0, self.registry.get_sample_value('c'))
4343
raised = False
4444
try:
45-
with self.counter.countExceptions():
45+
with self.counter.count_exceptions():
4646
raise ValueError
4747
except:
4848
raised = True
@@ -65,15 +65,15 @@ def test_gauge(self):
6565

6666
def test_function_decorator(self):
6767
self.assertEquals(0, self.registry.get_sample_value('g'))
68-
@self.gauge.trackInprogress()
68+
@self.gauge.track_inprogress()
6969
def f():
7070
self.assertEquals(1, self.registry.get_sample_value('g'))
7171
f()
7272
self.assertEquals(0, self.registry.get_sample_value('g'))
7373

7474
def test_block_decorator(self):
7575
self.assertEquals(0, self.registry.get_sample_value('g'))
76-
with self.gauge.trackInprogress():
76+
with self.gauge.track_inprogress():
7777
self.assertEquals(1, self.registry.get_sample_value('g'))
7878
self.assertEquals(0, self.registry.get_sample_value('g'))
7979

0 commit comments

Comments
 (0)