Class: SqsPoller::Metrics::SqsStatsReporter
- Inherits:
-
Object
- Object
- SqsPoller::Metrics::SqsStatsReporter
- Defined in:
- lib/sqspoller/metrics/queue_stats_reporter.rb
Constant Summary collapse
- DEFAULT_REPORTING_DELAY =
Default reporting delay is 60 seconds
60
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SqsStatsReporter
constructor
A new instance of SqsStatsReporter.
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SqsStatsReporter
Returns a new instance of SqsStatsReporter.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sqspoller/metrics/queue_stats_reporter.rb', line 14 def initialize( = {}) @running = true @logger = SqsPoller::Logger.get_new_logger(self.class.name) if [:queue_controller] == nil raise "Need an agent to report data from" end delay = [:delay] || DEFAULT_REPORTING_DELAY queue_controller = [:queue_controller] Thread.new { while @running sleep delay next if queue_controller.pollers.size == 0 queue_controller.pollers.each do |queue_name, pollers| pollers.each.with_index(1) do |poller, index| stats = poller.get_poller_stats next if stats == nil @logger.info("Queue: #{queue_name}, Worker: #{index} started: #{stats.polling_started_at}, requests: #{stats.request_count}, messages: #{stats.}, last-timestamp: #{stats.}") end end end } end |
Instance Method Details
#stop ⇒ Object
10 11 12 |
# File 'lib/sqspoller/metrics/queue_stats_reporter.rb', line 10 def stop @running = false end |