Class: ResqueToCloudwatch::QueueLengthCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/resque_to_cloudwatch/collectors.rb

Instance Method Summary collapse

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_valueObject



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_nameObject



15
16
17
# File 'lib/resque_to_cloudwatch/collectors.rb', line 15

def metric_name
  "resque_queues"
end

#to_sObject



19
20
21
# File 'lib/resque_to_cloudwatch/collectors.rb', line 19

def to_s
  metric_name
end