def timer(*func, **kwargs):
 key = kwargs.get('key', None)
 test_only = kwargs.get('test_only', True)
 def decorator(func):
  @functools.wraps(func)
  def wrapper(*args, **kw):
   if (test_only and (not settings.IN_TEST_SUITE)):
    return func(*args, **kw)
   else:
    name = (key if key else ('%s.%s' % (func.__module__, func.__name__)))
    with statsd.timer(('timer.%s' % name)):
     return func(*args, **kw)
  return wrapper
 if func:
  return decorator(func[0])
 return decorator

def timer ( * func , ** kwargs ) : key = kwargs . get ( 'key' , None ) test_only = kwargs . get ( 'test_only' , True ) def decorator ( func ) : @ functools . wraps ( func ) def wrapper ( * args , ** kw ) : if ( test_only and ( not settings . IN_TEST_SUITE ) ) : return func ( * args , ** kw ) else : name = ( key if key else ( '%s.%s' % ( func . __module__ , func . __name__ ) ) ) with statsd . timer ( ( 'timer.%s' % name ) ) : return func ( * args , ** kw ) return wrapper if func : return decorator ( func [ 0 ] ) return decorator
wrapper around dog_stats_api .