Class: ResqueToCloudwatch::GraphiteSender

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GraphiteSender

Pass an instance of ResqueToCloudwatch::Config



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

def initialize(config)
  @config = config
end

Instance Method Details

#inspectObject



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

def inspect
  to_s
end

#send_value(value, metric_name) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/resque_to_cloudwatch/graphite_sender.rb', line 11

def send_value(value, metric_name)
  graphite = Graphite.new({:host => @config.graphite_host, :port => @config.graphite_port})
  graphite.send_metrics({
    "resque_to_cloudwatch.#{@config.namespace}.#{metric_name}.#{@config.hostname}.#{@config.project}" => value
  })
  $log.info "GraphiteSender: sent metric value #{value} for #{metric_name}"
end

#to_sObject



23
24
25
# File 'lib/resque_to_cloudwatch/graphite_sender.rb', line 23

def to_s
  "GraphiteSender"
end