Created
September 11, 2012 22:06
-
-
Save ColinDKelley/3702480 to your computer and use it in GitHub Desktop.
rr_monitoring
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
module RRMonitoring | |
class Statistic | |
STATS_HOST = "stats.ringrevenue.net" | |
STATS_PORT = 8125 | |
def timing(name, &blk) | |
start = Time.now | |
yield | |
finish = Time.now | |
elapsed = ((finish - start) * 1000.0).to_i | |
send_stat("#{name}:#{elapsed}|ms") | |
end | |
def count(name, number) | |
send_stat("#{name}:#{number}|c") | |
end | |
def gauge(name, value) | |
send_stat("#{name}:#{value}|g") | |
end | |
def socket | |
@socket ||= UDPSocket.new | |
end | |
def send_stat(descriptor) | |
socket.send(descriptor, 0, STATS_HOST, STATS_PORT) | |
end | |
end | |
end | |
@@statistic = RRMonitoring::Statistic.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment