Class: StatsdHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/resque-statsd.rb

Class Method Summary collapse

Class Method Details

.graphite_hostObject



6
7
8
# File 'lib/resque-statsd.rb', line 6

def self.graphite_host
  return @graphite_host || ENV['GRAPHITE_HOST'] || 'localhost'
end

.graphite_host=(val) ⇒ Object



9
10
11
# File 'lib/resque-statsd.rb', line 9

def self.graphite_host=(val)
  @graphite_host = val
end

.graphite_portObject



13
14
15
# File 'lib/resque-statsd.rb', line 13

def self.graphite_port
  return @graphite_port || ENV['GRAPHITE_PORT'] || 8125
end

.graphite_port=(val) ⇒ Object



16
17
18
# File 'lib/resque-statsd.rb', line 16

def self.graphite_port=(val)
  @graphite_port = val
end

.namespaceObject



20
21
22
# File 'lib/resque-statsd.rb', line 20

def self.namespace
  return @namespace || ENV['GRAPHITE_NAMESPACE'] || 'resque'
end

.namespace=(val) ⇒ Object



23
24
25
# File 'lib/resque-statsd.rb', line 23

def self.namespace=(val)
  @namespace = val
end

.statsdObject

Set up the client lazily, to minimize order-of-operations headaches.



28
29
30
31
32
33
34
# File 'lib/resque-statsd.rb', line 28

def self.statsd
  if(@stats.nil?)
    @statsd = Statsd.new(graphite_host, graphite_port)
    @statsd.namespace = namespace
  end
  return @statsd
end