Class: Cloudwatch::Sender::Fetcher::SQS

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudwatch/sender/fetcher/sqs.rb

Constant Summary collapse

START_TIME =
1200

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloudwatch, sender) ⇒ SQS

Returns a new instance of SQS.



7
8
9
10
# File 'lib/cloudwatch/sender/fetcher/sqs.rb', line 7

def initialize(cloudwatch, sender)
  @cloudwatch = cloudwatch
  @sender = sender
end

Instance Attribute Details

#cloudwatchObject (readonly)

Returns the value of attribute cloudwatch.



5
6
7
# File 'lib/cloudwatch/sender/fetcher/sqs.rb', line 5

def cloudwatch
  @cloudwatch
end

#senderObject (readonly)

Returns the value of attribute sender.



5
6
7
# File 'lib/cloudwatch/sender/fetcher/sqs.rb', line 5

def sender
  @sender
end

Instance Method Details

#metrics(component_meta, metric) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cloudwatch/sender/fetcher/sqs.rb', line 14

def metrics(component_meta, metric)
  resp = cloudwatch.get_metric_statistics(
    :namespace   => component_meta["namespace"],
    :metric_name => metric["name"],
    :dimensions  => [{ :name  => "QueueName",
                       :value => component_meta["queue_name"] }],
    :start_time  => Time.now - START_TIME,
    :end_time    => Time.now,
    :period      => 60,
    :statistics  => metric["statistics"],
    :unit        => metric["unit"]
  )
  name = component_meta["namespace"].downcase
  name_metrics(resp, name, metric["statistics"], component_meta["queue_name"])
end