def __init__(self, metric_base, tags=None, stats=None): """ metric_base is add to the beginning of the "attempted", "duration", and "completed" metrics emited. tags is a list of string tags (in the format ["key:value", ..]) """ self._metric_base = metric_base self._tags = tags or [] self._metric_attempted = '{}.attempted'.format(self._metric_base) self._metric_duration = '{}.duration'.format(self._metric_base) self._metric_completed = '{}.completed'.format(self._metric_base) self._stats = stats or client() self._elapsed = None
def decorator(*args, **kwargs): stats = client() with stats.timer(name, tags=tags): return f(*args, **kwargs)
def decorator(*args, **kwargs): stats = client() ret = f(*args, **kwargs) stats.decr(name, tags=tags) return ret
def decorator(*args, **kwargs): stats = client() with stats.timer(name): return f(*args, **kwargs)
def decorator(*args, **kwargs): stats = client() ret = f(*args, **kwargs) stats.decr(name) return ret
def decorator(*args, **kwargs): stats = client() ret = f(*args, **kwargs) stats.incr(name) return ret
def test_configure_and_create(): statsdecor.configure(port=9999) client = statsdecor.client() assert client._addr[1] == 9999, 'port should match'