Object
# File lib/graphite-api/client.rb, line 9 def initialize opt @options = build_options validate opt.clone @buffer = GraphiteAPI::Buffer.new options @connectors = GraphiteAPI::Connector::Group.new options Zscheduler.every(options[:interval]){ send_metrics } unless options[:direct] end
# File lib/graphite-api/client.rb, line 20 def every interval, &block Zscheduler.every( interval ) { block.arity == 1 ? block.call(self) : block.call } end
increment keys
increment("key1","key2")
increment("key1","key2", {:by => 999})
increment("key1","key2", {:time => Time.at(123456)})
# File lib/graphite-api/client.rb, line 42 def increment(*keys) opt = {} opt.merge! keys.pop if keys.last.is_a? Hash by = opt.fetch(:by,1) time = opt.fetch(:time,Time.now) metric = keys.inject({}) {|h,k| h.tap { h[k] = by}} metrics(metric, time) end
# File lib/graphite-api/client.rb, line 51 def join sleep while buffer.new_records? end
# File lib/graphite-api/client.rb, line 55 def method_missing m, *args, &block Proxy.new( self ).send(m,*args,&block) end
# File lib/graphite-api/client.rb, line 24 def metrics metric, time = Time.now return if metric.empty? buffer.push :metric => metric, :time => time send_metrics if options[:direct] end
# File lib/graphite-api/client.rb, line 85 def build_options opt default_options.tap do |options_hash| options_hash[:backends].push expand_host opt.delete :graphite options_hash.merge! opt options_hash[:direct] = options_hash[:interval] == 0 options_hash[:slice] = 1 if options_hash[:direct] end end
Generated with the Darkfish Rdoc Generator 2.