lib/statsd/client.rb in dawanda-statsd-client-0.1.4 vs lib/statsd/client.rb in dawanda-statsd-client-0.1.5

- old
+ new

@@ -3,30 +3,18 @@ require 'yaml' class Statsd class << self def increment(metric, options={}) - if options.is_a?(Fixnum) - value = options - sample_rate = 1 - else - value = (options[:by] || 1) - sample_rate = (options[:sample_rate] || 1) - end - client.update_stats(metric, value*factor, sample_rate) + value = options.is_a?(Fixnum) ? options : (options[:by] || 1) + client.update_stats(metric, value*factor, (options[:sample_rate] || 1)) end alias_method :inc, :increment def decrement(metric, options={}) - if options.is_a?(Fixnum) - value = options - sample_rate = 1 - else - value = (options[:by] || 1) - sample_rate = (options[:sample_rate] || 1) - end - client.update_stats(metric, value*factor*(-1), sample_rate) + value = options.is_a?(Fixnum) ? options : (options[:by] || 1) + client.update_stats(metric, value*factor*(-1), (options[:sample_rate] || 1)) end alias_method :dec, :decrement def timing(metric, value) client.timing(metric, value) @@ -133,10 +121,9 @@ end private def send(data, sample_rate = 1) - #puts "sending #{data} with sample #{sample_rate}" sampled_data = {} if sample_rate < 1 if Kernel.rand <= sample_rate data.each do |k,v|