Created
July 31, 2015 18:13
-
-
Save blurredbits/db05490c5f9bcd09531a to your computer and use it in GitHub Desktop.
Sample for code for StatsD Timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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