Skip to content
This repository
Browse code

Refactor Statsd#sampled

  • Loading branch information...
commit 334f665bd83fc0fd057a6213db8632dd4ffa273e 1 parent d85787d
Rein Henrichs authored February 20, 2011
3  lib/statsd.rb
@@ -36,8 +36,7 @@ def timing(stat, ms, sample_rate=1); send stat, ms, 'ms', sample_rate end
36 36
   private
37 37
 
38 38
   def sampled(sample_rate)
39  
-    return if sample_rate < 1 and rand > sample_rate
40  
-    yield
  39
+    yield unless sample_rate < 1 and rand > sample_rate
41 40
   end
42 41
 
43 42
   def send(stat, delta, type, sample_rate)
1  spec/statsd_spec.rb
@@ -93,7 +93,6 @@ def socket; @socket ||= FakeUDPSocket.new end
93 93
       end
94 94
     end
95 95
   end
96  
-
97 96
 end
98 97
 
99 98
 describe Statsd do

0 notes on commit 334f665

Please sign in to comment.
Something went wrong with that request. Please try again.