Class: Metrics::Agent

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/ruby-metrics/agent.rb,
lib/ruby-metrics/integration/webrick.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #logger

Constructor Details

#initialize(options = {}) ⇒ Agent

Returns a new instance of Agent.



21
22
23
# File 'lib/ruby-metrics/agent.rb', line 21

def initialize(options = {})
  @instruments = {}
end

Instance Attribute Details

#instrumentsObject (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(options = {})
  Integration::WEBrick.start(options.merge(:agent => self))
end

#timer(name, options = {}) ⇒ Object



39
40
41
# File 'lib/ruby-metrics/agent.rb', line 39

def timer(name, options = {})
  @instruments[name] ||= Instruments::Timer.new(options)
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