Skip to content

Commit 3b58b5e

Browse files
committed
Suggestion from Julius
1 parent 20d8be0 commit 3b58b5e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

prometheus_client/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,19 @@ def inc(self, amount=1):
169169
self._value += amount
170170

171171
@contextmanager
172-
def trackBlockRaises(self):
172+
def countBlockExceptions(self):
173173
"""Decorator to increment if a block raises an exception."""
174174
try:
175175
yield
176176
except Exception, e:
177177
self.inc()
178178
raise e
179179

180-
def trackFunctionRaises(self, f):
180+
def countFunctionExceptions(self, f):
181181
"""Decorator to increment if a function raises an exception."""
182182
@wraps(f)
183183
def wrapper(*args, **kwargs):
184-
with self.trackBlockRaises():
184+
with self.countBlockExceptions():
185185
return f(*args, **kwargs)
186186
return wrapper
187187

tests/test_client.py

Lines changed: 3 additions & 3 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.trackFunctionRaises
22+
@self.counter.countFunctionExceptions
2323
def f(r):
2424
if r:
2525
raise Exception
@@ -34,12 +34,12 @@ def f(r):
3434
self.assertEquals(1, self.registry.get_sample_value('c'))
3535

3636
def test_block_decorator(self):
37-
with self.counter.trackBlockRaises():
37+
with self.counter.countBlockExceptions():
3838
pass
3939
self.assertEquals(0, self.registry.get_sample_value('c'))
4040
raised = False
4141
try:
42-
with self.counter.trackBlockRaises():
42+
with self.counter.countBlockExceptions():
4343
raise Exception
4444
except:
4545
raised = True

0 commit comments

Comments
 (0)