Class: Metrics::Agent
- Inherits:
-
Object
- Object
- Metrics::Agent
- Includes:
- Logging
- Defined in:
- lib/ruby-metrics/agent.rb,
lib/ruby-metrics/integration/webrick.rb
Instance Attribute Summary collapse
-
#instruments ⇒ Object
(also: #registered)
readonly
Returns the value of attribute instruments.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#reporters ⇒ Object
readonly
Returns the value of attribute reporters.
Instance Method Summary collapse
- #as_json(*_) ⇒ Object
- #counter(name, units = '') ⇒ Object
- #exponential_histogram(name) ⇒ Object
- #gauge(name, units = '', &block) ⇒ Object
-
#initialize(options = {}) ⇒ Agent
constructor
A new instance of Agent.
- #meter(name, units = '') ⇒ Object
- #report_periodically(delay = nil) ⇒ Object
- #report_to(name, service) ⇒ Object
- #send_metrics! ⇒ Object
- #start(options = {}) ⇒ Object
- #timer(name, units = '', options = {}) ⇒ Object
- #to_json(*_) ⇒ Object
- #uniform_histogram(name) ⇒ Object (also: #histogram)
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ Agent
Returns a new instance of Agent.
22 23 24 25 |
# File 'lib/ruby-metrics/agent.rb', line 22 def initialize( = {}) @instruments = {} @reporters = {} end |
Instance Attribute Details
#instruments ⇒ Object (readonly) Also known as: registered
Returns the value of attribute instruments.
20 21 22 |
# File 'lib/ruby-metrics/agent.rb', line 20 def instruments @instruments end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
20 21 22 |
# File 'lib/ruby-metrics/agent.rb', line 20 def reporter @reporter end |
#reporters ⇒ Object (readonly)
Returns the value of attribute reporters.
20 21 22 |
# File 'lib/ruby-metrics/agent.rb', line 20 def reporters @reporters end |
Instance Method Details
#as_json(*_) ⇒ Object
70 71 72 |
# File 'lib/ruby-metrics/agent.rb', line 70 def as_json(*_) @instruments end |
#counter(name, units = '') ⇒ Object
29 30 31 |
# File 'lib/ruby-metrics/agent.rb', line 29 def counter(name, units = '') @instruments[name] ||= Instruments::Counter.new(:units => units) end |
#exponential_histogram(name) ⇒ Object
52 53 54 |
# File 'lib/ruby-metrics/agent.rb', line 52 def exponential_histogram(name) @instruments[name] ||= Instruments::ExponentialHistogram.new end |
#gauge(name, units = '', &block) ⇒ Object
37 38 39 |
# File 'lib/ruby-metrics/agent.rb', line 37 def gauge(name, units = '', &block) @instruments[name] ||= Instruments::Gauge.new(:units => units, &block) end |
#meter(name, units = '') ⇒ Object
33 34 35 |
# File 'lib/ruby-metrics/agent.rb', line 33 def meter(name, units = '') @instruments[name] ||= Instruments::Meter.new(:units => units) end |
#report_periodically(delay = nil) ⇒ Object
66 67 68 |
# 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) ⇒ Object
56 57 58 |
# File 'lib/ruby-metrics/agent.rb', line 56 def report_to(name, service) @reporters[name] ||= service end |
#send_metrics! ⇒ Object
60 61 62 63 64 |
# File 'lib/ruby-metrics/agent.rb', line 60 def send_metrics! @reporters.each do |name, service| service.report(self) end end |
#start(options = {}) ⇒ Object
8 9 10 |
# File 'lib/ruby-metrics/integration/webrick.rb', line 8 def start( = {}) Integration::WEBrick.start(.merge(:agent => self)) end |
#timer(name, units = '', options = {}) ⇒ Object
41 42 43 |
# File 'lib/ruby-metrics/agent.rb', line 41 def timer(name, units = '', = {}) @instruments[name] ||= Instruments::Timer.new(.merge(:units => units)) end |
#to_json(*_) ⇒ Object
74 75 76 |
# File 'lib/ruby-metrics/agent.rb', line 74 def to_json(*_) as_json.to_json end |
#uniform_histogram(name) ⇒ Object Also known as: histogram
45 46 47 |
# File 'lib/ruby-metrics/agent.rb', line 45 def uniform_histogram(name) @instruments[name] ||= Instruments::UniformHistogram.new end |