class Statsd
Public Class Methods
client()
click to toggle source
# File lib/statsd/client.rb, line 36 def client return Statsd::DummyClient if deactivated? @client ||= Statsd::Client.new(host, port, tcp?) end
config()
click to toggle source
# File lib/statsd/client.rb, line 41 def config home = File.expand_path('~') files = ["#{home}/.statsd-client.yml", '/etc/statsd-client.yml'] files.each do |file| return YAML.load(File.read(file)) if File.exist?(file) end raise "No config found: #{files.join(' or ')}" end
deactivated?()
click to toggle source
# File lib/statsd/client.rb, line 67 def deactivated? config['deactivated'] || false end
decrement(metric, options={})
click to toggle source
# File lib/statsd/client.rb, line 19 def decrement(metric, options={}) if options.is_a?(Fixnum) value = options sample_rate = 1 else value = (options[:by] || 1) sample_rate = (options[:sample_rate] || 1) end client.update_stats(metric, value*factor*(-1), sample_rate) end
Also aliased as: dec
factor()
click to toggle source
statds reports with default configs 1/10 of actual value
# File lib/statsd/client.rb, line 63 def factor config['factor'] || 1 end
host()
click to toggle source
# File lib/statsd/client.rb, line 50 def host config['host'] || 'localhost' end
increment(metric, options={})
click to toggle source
# File lib/statsd/client.rb, line 7 def increment(metric, options={}) if options.is_a?(Fixnum) value = options sample_rate = 1 else value = (options[:by] || 1) sample_rate = (options[:sample_rate] || 1) end client.update_stats(metric, value*factor, sample_rate) end
Also aliased as: inc
port()
click to toggle source
# File lib/statsd/client.rb, line 54 def port config['port'] || 8125 end
tcp?()
click to toggle source
# File lib/statsd/client.rb, line 58 def tcp? config['tcp'] end
timing(metric, value)
click to toggle source
# File lib/statsd/client.rb, line 31 def timing(metric, value) client.timing(metric, value) end
Also aliased as: time