in clay/stats.py [0:0]
def wrapper(prefix):
'''
Decorator that logs timing, call count, and exception count statistics to
statsd. Given a prefix of "example", the following keys would be created:
stats.counts.example.calls
stats.counts.example.exceptions
stats.timers.example.duration
:param: prefix
:type key: Prefix for stats keys to be created under
'''
def clay_stats_wrapper(func):
@functools.wraps(func)
def wrap(*args, **kwargs):
count('%s.calls' % prefix, 1)
try:
with Timer('%s.duration' % prefix):
return func(*args, **kwargs)
except Exception:
count('%s.exceptions' % prefix, 1)
raise
return wrap
return clay_stats_wrapper