Function decorator for tracking timing information
    on a function's invocation.

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

def timed(name, tags=None):
    """Function decorator for tracking timing information
    on a function's invocation.

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