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.
Instance Method Summary collapse
- #as_json(*_) ⇒ Object
- #counter(name) ⇒ Object
- #exponential_histogram(name) ⇒ Object
- #gauge(name, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Agent
constructor
A new instance of Agent.
- #meter(name) ⇒ Object
- #start(options = {}) ⇒ Object
- #timer(name, 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.
21 22 23 |
# File 'lib/ruby-metrics/agent.rb', line 21 def initialize( = {}) @instruments = {} end |
Instance Attribute Details
#instruments ⇒ Object (readonly) Also known as: registered
Returns the value of attribute instruments.
19 20 21 |
# File 'lib/ruby-metrics/agent.rb', line 19 def instruments @instruments end |
Instance Method Details
#as_json(*_) ⇒ Object
54 55 56 |
# File 'lib/ruby-metrics/agent.rb', line 54 def as_json(*_) @instruments end |
#counter(name) ⇒ Object
27 28 29 |
# File 'lib/ruby-metrics/agent.rb', line 27 def counter(name) @instruments[name] ||= Instruments::Counter.new end |
#exponential_histogram(name) ⇒ Object
50 51 52 |
# File 'lib/ruby-metrics/agent.rb', line 50 def exponential_histogram(name) @instruments[name] ||= Instruments::ExponentialHistogram.new end |
#gauge(name, &block) ⇒ Object
35 36 37 |
# File 'lib/ruby-metrics/agent.rb', line 35 def gauge(name, &block) @instruments[name] ||= Instruments::Gauge.new(&block) end |
#meter(name) ⇒ Object
31 32 33 |
# File 'lib/ruby-metrics/agent.rb', line 31 def meter(name) @instruments[name] ||= Instruments::Meter.new 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, options = {}) ⇒ Object
39 40 41 |
# File 'lib/ruby-metrics/agent.rb', line 39 def timer(name, = {}) @instruments[name] ||= Instruments::Timer.new() end |
#to_json(*_) ⇒ Object
58 59 60 |
# File 'lib/ruby-metrics/agent.rb', line 58 def to_json(*_) as_json.to_json end |
#uniform_histogram(name) ⇒ Object Also known as: histogram
43 44 45 |
# File 'lib/ruby-metrics/agent.rb', line 43 def uniform_histogram(name) @instruments[name] ||= Instruments::UniformHistogram.new end |