Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from gburt/master
Browse files Browse the repository at this point in the history
do less work if not sampled
  • Loading branch information
technoweenie committed Dec 30, 2011
2 parents f18a9c3 + 1133309 commit 1b945ac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/statsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1b945ac

Please sign in to comment.