Class: Resque::CloudWatch::Metrics::Metric
- Inherits:
-
Object
- Object
- Resque::CloudWatch::Metrics::Metric
- Defined in:
- lib/resque/cloudwatch/metrics/metric.rb
Constant Summary collapse
- @@mutex =
Mutex.new
Class Method Summary collapse
Instance Method Summary collapse
- #failed ⇒ Object
-
#initialize(time, namespace, info, queue_sizes, previous_processed) ⇒ Metric
constructor
A new instance of Metric.
- #pending ⇒ Object
- #processed ⇒ Object
- #processing ⇒ Object
- #queues ⇒ Object
- #to_cloudwatch_metric_data ⇒ Object
- #workers ⇒ Object
- #working ⇒ Object
Constructor Details
#initialize(time, namespace, info, queue_sizes, previous_processed) ⇒ Metric
44 45 46 47 48 49 50 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 44 def initialize(time, namespace, info, queue_sizes, previous_processed) @time = time @namespace = namespace @info = info @queue_sizes = queue_sizes @previous_processed = previous_processed end |
Class Method Details
.create(namespace) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 12 def create(namespace) @@mutex.synchronize do Resque.redis.namespace = namespace new( Time.now, namespace, Resque.info, current_queue_sizes, get_previous_processed(namespace), ).tap do |metric| set_previous_processed(namespace, metric.processed) end end end |
Instance Method Details
#failed ⇒ Object
54 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 54 def failed; @info[:failed]; end |
#pending ⇒ Object
52 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 52 def pending; @info[:pending]; end |
#processed ⇒ Object
53 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 53 def processed; @info[:processed]; end |
#processing ⇒ Object
59 60 61 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 59 def processing incremental_size_of_processed + working end |
#queues ⇒ Object
55 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 55 def queues; @info[:queues]; end |
#to_cloudwatch_metric_data ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 63 def to_cloudwatch_metric_data dimensions = [{ name: 'namespace', value: @namespace.to_s }] i(pending processed failed queues workers working processing).map do |key| build_cloudwatch_metric_datum(key.to_s.capitalize, public_send(key)) end + @queue_sizes.map do |name, size| build_cloudwatch_metric_datum('Pending', size, queue: name) end end |
#workers ⇒ Object
56 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 56 def workers; @info[:workers]; end |
#working ⇒ Object
57 |
# File 'lib/resque/cloudwatch/metrics/metric.rb', line 57 def working; @info[:working]; end |