Permalink
Browse files

do less work if not sampled

  • Loading branch information...
1 parent f18a9c3 commit 1133309fd6076cdb8d4da8974b646d179c6d5cfd @gburt gburt committed Dec 30, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/statsd.rb
View
@@ -94,9 +94,11 @@ def sampled(sample_rate)
end
def send(stat, delta, type, sample_rate=1)
- prefix = "#{@namespace}." unless @namespace.nil?
- stat = stat.to_s.gsub('::', '.').gsub(RESERVED_CHARS_REGEX, '_')
- sampled(sample_rate) { send_to_socket("#{prefix}#{stat}:#{delta}|#{type}#{'|@' << sample_rate.to_s if sample_rate < 1}") }
+ sampled(sample_rate) do
+ prefix = "#{@namespace}." unless @namespace.nil?
+ stat = stat.to_s.gsub('::', '.').gsub(RESERVED_CHARS_REGEX, '_')
+ send_to_socket("#{prefix}#{stat}:#{delta}|#{type}#{'|@' << sample_rate.to_s if sample_rate < 1}")
+ end
end
def send_to_socket(message)

0 comments on commit 1133309

Please sign in to comment.