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