Skip to content
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```

Expand Down
6 changes: 3 additions & 3 deletions prometheus_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
10 changes: 5 additions & 5 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -65,15 +65,15 @@ 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()
self.assertEquals(0, self.registry.get_sample_value('g'))

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'))

Expand Down