Skip to content

Instantly share code, notes, and snippets.

@blurredbits
Created July 31, 2015 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blurredbits/db05490c5f9bcd09531a to your computer and use it in GitHub Desktop.
Save blurredbits/db05490c5f9bcd09531a to your computer and use it in GitHub Desktop.
Sample for code for StatsD Timer
require 'statsd-ruby'
statsd = Statsd.new('localhost', 8125)
# Single call to statsd timer.
statsd.time("timer_data") do
timer_data = 1 + Random.rand(6)
puts timer_data
sleep timer_data
end
# Multiple calls to statsd timer.
10.times do
statsd.time("timer_data") do
timer_data = 1 + Random.rand(6)
puts timer_data
sleep timer_data
end
end
# Statsd Timer call without a code block
10.times do
fake_data = 1 + Random.rand(6)
puts fake_data
statsd.timing "fake_timer_data", fake_data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment