Class: Metrics::Reporter

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/ruby-metrics/reporter.rb

Constant Summary collapse

DEFAULT_REPORTING_DELAY =

Default reporting delay is 60 seconds

60

Instance Method Summary collapse

Methods included from Logging

included, #logger

Constructor Details

#initialize(options = {}) ⇒ Reporter

Returns a new instance of Reporter.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ruby-metrics/reporter.rb', line 12

def initialize(options = {})
  @running = true

  if options[:agent] == nil
    raise "Need an agent to report data from"
  end

  delay = options[:delay] || DEFAULT_REPORTING_DELAY
  agent = options[:agent] 

  Thread.new {
    while @running
      agent.reporters.each do |name, service|
        service.report(agent)
      end
      sleep delay
    end
  }
end

Instance Method Details

#stopObject



8
9
10
# File 'lib/ruby-metrics/reporter.rb', line 8

def stop
  @running = false
end