Class: ResqueToCloudwatch::Sender

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Sender

Pass an instance of CloudwatchToResque::Config



7
8
9
# File 'lib/resque_to_cloudwatch/sender.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#send_value(value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/resque_to_cloudwatch/sender.rb', line 11

def send_value(value)
  cw = AWS::CloudWatch.new
  cw.client.put_metric_data({
    :namespace      => 'F3D/resque_queues',
    :metric_data    => [
      :metric_name  => "jobs_queued",
      :dimensions   => [
        {
          :name  => 'hostname',
          :value => @config.hostname
        },
        {
          :name  => 'project',
          :value => @config.project
        }
      ],
      :value => value,
      :unit  => 'Count'
    ]
  })
  $log.info "Sent metric value #{value}"
end