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, options = {}) ⇒ 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.
23 24 25 |
# File 'lib/ruby-metrics/agent.rb', line 23 def initialize( = {}) @instruments = {} end |
Instance Attribute Details
#instruments ⇒ Object (readonly) Also known as: registered
Returns the value of attribute instruments.
21 22 23 |
# File 'lib/ruby-metrics/agent.rb', line 21 def instruments @instruments end |
Instance Method Details
#as_json(*_) ⇒ Object
56 57 58 |
# File 'lib/ruby-metrics/agent.rb', line 56 def as_json(*_) @instruments end |
#counter(name) ⇒ Object
29 30 31 |
# File 'lib/ruby-metrics/agent.rb', line 29 def counter(name) @instruments[name] ||= Instruments::Counter.new 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, &block) ⇒ Object
37 38 39 |
# File 'lib/ruby-metrics/agent.rb', line 37 def gauge(name, &block) @instruments[name] ||= Instruments::Gauge.new(&block) end |
#meter(name, options = {}) ⇒ Object
33 34 35 |
# File 'lib/ruby-metrics/agent.rb', line 33 def meter(name, = {}) @instruments[name] ||= [:post_process] ? Instruments::PostProcessMeter.new() : 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
41 42 43 |
# File 'lib/ruby-metrics/agent.rb', line 41 def timer(name, = {}) @instruments[name] ||= [:post_process] ? Instruments::PostProcessTimer.new() : Instruments::Timer.new() end |
#to_json(*_) ⇒ Object
60 61 62 |
# File 'lib/ruby-metrics/agent.rb', line 60 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 |