Class: Napa::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/napa/stats.rb

Class Method Summary collapse

Class Method Details

.emitterObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/napa/stats.rb', line 9

def emitter
  unless @emitter
    # Log an error if StatsD settings are not configured
    message = 'StatsD host and port not configured in environment variables, using default settings'
    Napa::Logger.logger.warn message unless ENV['STATSD_HOST'] && ENV['STATSD_PORT']

    # Create a new StatsD emitter with the service name as the namespace
    # Defaults to localhost port 8125 if env vars are nil
    @emitter = Statsd.new(ENV['STATSD_HOST'], ENV['STATSD_PORT']).tap { |sd| sd.namespace = Napa::Identity.name }
  end
  @emitter
end

.emitter=(emitter) ⇒ Object



5
6
7
# File 'lib/napa/stats.rb', line 5

def emitter=(emitter)
  @emitter = emitter
end