Class: ResqueToCloudwatch::WorkRemainingCollector
- Inherits:
-
Object
- Object
- ResqueToCloudwatch::WorkRemainingCollector
- Defined in:
- lib/resque_to_cloudwatch/collectors.rb
Instance Method Summary collapse
- #get_value ⇒ Object
-
#initialize(config) ⇒ WorkRemainingCollector
constructor
A new instance of WorkRemainingCollector.
- #metric_name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ WorkRemainingCollector
Returns a new instance of WorkRemainingCollector.
71 72 73 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 71 def initialize(config) @config = config end |
Instance Method Details
#get_value ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 75 def get_value redis = Redis.new(:host => @config.redis_host, :port => @config.redis_port) working = redis.smembers('resque:workers').select do |worker_key| redis.exists("resque:worker:#{worker_key}") end.length queue_length = redis.smembers('resque:queues').map do |queue_key| redis.llen("resque:queue:#{queue_key}") end.reduce(:+) working + queue_length end |
#metric_name ⇒ Object
86 87 88 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 86 def metric_name "resque_work_remaining" end |
#to_s ⇒ Object
90 91 92 |
# File 'lib/resque_to_cloudwatch/collectors.rb', line 90 def to_s metric_name end |