class Metrics::Agent

Attributes

instruments[R]
registered[R]
reporter[R]
reporters[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/ruby-metrics/agent.rb, line 22
def initialize(options = {})
  @instruments = {}
  @reporters = {}
end

Public Instance Methods

as_json(*_) click to toggle source
# File lib/ruby-metrics/agent.rb, line 74
def as_json(*_)
  @instruments
end
counter(name, units = '') click to toggle source
# File lib/ruby-metrics/agent.rb, line 29
def counter(name, units = '')
  @instruments[name] ||= Instruments::Counter.new(:units => units)
end
exponential_histogram(name) click to toggle source
# File lib/ruby-metrics/agent.rb, line 52
def exponential_histogram(name)
  @instruments[name] ||= Instruments::ExponentialHistogram.new
end
gauge(name, units = '', &block) click to toggle source
# File lib/ruby-metrics/agent.rb, line 37
def gauge(name, units = '', &block)
  @instruments[name] ||= Instruments::Gauge.new(:units => units, &block)
end
histogram(name)

For backwards compatibility

Alias for: uniform_histogram
meter(name, units = '') click to toggle source
# File lib/ruby-metrics/agent.rb, line 33
def meter(name, units = '')
  @instruments[name] ||= Instruments::Meter.new(:units => units)
end
report_periodically(delay = nil) click to toggle source
# File lib/ruby-metrics/agent.rb, line 66
def report_periodically(delay = nil)
  @reporter = Reporter.new({:agent => self, :delay => delay})
end
report_to(name, service) click to toggle source
# File lib/ruby-metrics/agent.rb, line 56
def report_to(name, service)
  @reporters[name] ||= service
end
send_metrics!() click to toggle source
# File lib/ruby-metrics/agent.rb, line 60
def send_metrics!
  @reporters.each do |name, service|
    service.report(self)
  end
end
start(options = {}) click to toggle source
# File lib/ruby-metrics/integration/webrick.rb, line 8
def start(options = {})
  Integration::WEBrick.start(options.merge(:agent => self))
end
stop_reporting() click to toggle source
# File lib/ruby-metrics/agent.rb, line 70
def stop_reporting
  @reporter.stop
end
timer(name, units = '', options = {}) click to toggle source
# File lib/ruby-metrics/agent.rb, line 41
def timer(name, units = '', options = {})
  @instruments[name] ||= Instruments::Timer.new(options.merge(:units => units))
end
to_json(*_) click to toggle source
# File lib/ruby-metrics/agent.rb, line 78
def to_json(*_)
  as_json.to_json
end
uniform_histogram(name) click to toggle source
# File lib/ruby-metrics/agent.rb, line 45
def uniform_histogram(name)
  @instruments[name] ||= Instruments::UniformHistogram.new
end
Also aliased as: histogram