def time(stat, opts=EMPTY_OPTIONS)
      opts = {:sample_rate => opts} if opts.is_a? Numeric
      start = (PROCESS_TIME_SUPPORTED ? Process.clock_gettime(Process::CLOCK_MONOTONIC) : Time.now.to_f)
      return yield
    ensure
      finished = (PROCESS_TIME_SUPPORTED ? Process.clock_gettime(Process::CLOCK_MONOTONIC) : Time.now.to_f)
      timing(stat, ((finished - start) * 1000).round, opts)
    end
def time(stat, opts=EMPTY_OPTIONS)
      opts = {:sample_rate => opts} if opts.is_a? Numeric
      start = (PROCESS_TIME_SUPPORTED ? Process.clock_gettime(Process::CLOCK_MONOTONIC) : Time.now.to_f)
      return yield
    ensure
      finished = (PROCESS_TIME_SUPPORTED ? Process.clock_gettime(Process::CLOCK_MONOTONIC) : Time.now.to_f)
      timing(stat, ((finished - start) * 1000).round, opts)
    end
Reports execution time of the provided block using {#timing}.

 If the block fails, the stat is still reported, then the error
 is reraised

 @param [String] stat stat name
 @param [Hash] opts the options to create the metric with
 @option opts [Numeric] :sample_rate sample rate, 1 for always
 @option opts [Array<String>] :tags An array of tags
 @yield The operation to be timed
 @see #timing
 @example Report the time (in ms) taken to activate an account
   $statsd.time('account.activate') { @account.activate! }