Class: ResqueToCloudwatch::QueueLengthCollector
- Inherits:
-
Object
- Object
- ResqueToCloudwatch::QueueLengthCollector
- Defined in:
- lib/resque_to_cloudwatch/collectors.rb
Instance Method Summary collapse
- #get_value ⇒ Object
-
#initialize(config) ⇒ QueueLengthCollector
constructor
A new instance of QueueLengthCollector.
- #metric_name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ QueueLengthCollector
Returns a new instance of QueueLengthCollector.
4 5 6 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 4 def initialize(config) @config = config end |
Instance Method Details
#get_value ⇒ Object
8 9 10 11 12 13 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 8 def get_value redis = Redis.new(:host => @config.redis_host, :port => @config.redis_port) redis.smembers('resque:queues').map do |queue_key| redis.llen("resque:queue:#{queue_key}") end.reduce(:+) end |
#metric_name ⇒ Object
15 16 17 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 15 def metric_name "resque_queues" end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 19 def to_s metric_name end |