class Watchman
Constants
- VERSION
Attributes
host[RW]
port[RW]
prefix[RW]
test_mode[RW]
Public Class Methods
benchmark(name, options = {}) { || ... }
click to toggle source
# File lib/watchman.rb, line 16 def benchmark(name, options = {}) result = nil time = Benchmark.measure do result = yield end timing(name, (time.real * 1000).floor, options) result end
decrement(name, options = {})
click to toggle source
# File lib/watchman.rb, line 36 def decrement(name, options = {}) submit(name, -1, :count, options) end
increment(name, options = {})
click to toggle source
# File lib/watchman.rb, line 32 def increment(name, options = {}) submit(name, 1, :count, options) end
submit(name, value, type = :gauge, options = {})
click to toggle source
# File lib/watchman.rb, line 40 def submit(name, value, type = :gauge, options = {}) metric = Watchman::MetricName.construct(name, prefix, options[:tags]) case type when :gauge then statsd_client.gauge(metric, value) when :timing then statsd_client.timing(metric, value) when :count then statsd_client.count(metric, value) else raise SubmitTypeError.new("Submit type '#{type}' is not recognized") end end
timing(name, value, options = {})
click to toggle source
# File lib/watchman.rb, line 28 def timing(name, value, options = {}) submit(name, value, :timing, options) end
Private Class Methods
statsd_client()
click to toggle source
# File lib/watchman.rb, line 53 def statsd_client if @test_mode == true Watchman::MockStatsd.new else @client ||= Statsd.new(@host, @port) end end