Esempio n. 1
0
    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
Esempio n. 2
0
 def decorator(*args, **kwargs):
     stats = client()
     with stats.timer(name, tags=tags):
         return f(*args, **kwargs)
Esempio n. 3
0
 def decorator(*args, **kwargs):
     stats = client()
     ret = f(*args, **kwargs)
     stats.decr(name, tags=tags)
     return ret
Esempio n. 4
0
 def decorator(*args, **kwargs):
     stats = client()
     with stats.timer(name):
         return f(*args, **kwargs)
Esempio n. 5
0
 def decorator(*args, **kwargs):
     stats = client()
     ret = f(*args, **kwargs)
     stats.decr(name)
     return ret
Esempio n. 6
0
 def decorator(*args, **kwargs):
     stats = client()
     ret = f(*args, **kwargs)
     stats.incr(name)
     return ret
Esempio n. 7
0
def test_configure_and_create():
    statsdecor.configure(port=9999)
    client = statsdecor.client()
    assert client._addr[1] == 9999, 'port should match'
Esempio n. 8
0
def test_configure_and_create():
    statsdecor.configure(port=9999)
    client = statsdecor.client()
    assert client._addr[1] == 9999, 'port should match'