'Factory to create methods which delegate to methods on
self.logger.statsd_client (an instance of StatsdClient).  The
created methods conditionally delegate to a method whose name is given
in \'statsd_func_name\'.  The created delegate methods are a no-op when
StatsD logging is not configured.
:param statsd_func_name: the name of a method on StatsdClient.'

def statsd_delegate(statsd_func_name):

    func = getattr(StatsdClient, statsd_func_name)
    @functools.wraps(func)
    def wrapped(self, *a, **kw):
        if getattr(self.logger, 'statsd_client'):
            return func(self.logger.statsd_client, *a, **kw)
    return wrapped
