Watchman
Watchman is your friend who monitors your processes so you don't have to.
Installation
gem "rt-watchman", :require => "watchman"
Usage
First, set up the host and the port of the metrics server:
Watchman.host = "localhost"
Watchman.port = 22345
To submit a simple value from your service:
Watchman.submit("number.of.kittens", 30)
To benchmark a part of your service:
Watchman.benchmark("time.to.wake.up") do
puts "Sleeping"
sleep 10
puts "Wake up"
end
To submit a time value in miliseconds:
Watchman.submit("number.of.kittens", 30, :timing)
Global metric prefix
If you want to prepend all the metric names with a prefix, do the following:
Watchman.prefix = "production.server1"
Then, all your metrics will be saved with that prefix. For example:
Watchman.submit("high.score", 100) # => production.server1.high.score = 100
Test mode for Watchman
In tests you can set the following:
Watchman.test_mode = true
That way watchman will use a stubbed client, and won't send any data to the metric server.