Function decorator for decrementing a statsd stat whenever
    a function is invoked.

    >>> from statsdecor.decorators import decrement
    >>> @decrement('my.metric')
    >>> def my_func():
    >>>     pass

def decrement(name, tags=None):
    """Function decorator for decrementing a statsd stat whenever
    a function is invoked.

    >>> from statsdecor.decorators import decrement
    >>> @decrement('my.metric')
    >>> def my_func():
    >>>     pass
    """
    def wrap(f):
        @wraps(f)
        def decorator(*args, **kwargs):
            stats = client()
            ret = f(*args, **kwargs)
            stats.decr(name, tags=tags)
            return ret
        return decorator
    return wrap