Class: NewRelic::Agent::Configuration::EnvironmentSource

Inherits:
DottedHash
  • Object
show all
Defined in:
lib/new_relic/agent/configuration/environment_source.rb

Instance Method Summary collapse

Methods inherited from DottedHash

#inspect, #to_hash

Constructor Details

#initializeEnvironmentSource

Returns a new instance of EnvironmentSource.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/new_relic/agent/configuration/environment_source.rb', line 5

def initialize
  string_map = {
    'NRCONFIG'              => :config_path,
    'NEW_RELIC_LICENSE_KEY' => :license_key,
    'NEWRELIC_LICENSE_KEY'  => :license_key,
    'NEW_RELIC_APP_NAME'    => :app_name,
    'NEWRELIC_APP_NAME'     => :app_name,
    'NEW_RELIC_HOST'        => :host,
    'NEW_RELIC_PORT'        => :port
  }.each do |key, val|
    self[val] = ENV[key] if ENV[key]
  end

  symbol_map = {
    'NEW_RELIC_DISPATCHER'  => :dispatcher,
    'NEWRELIC_DISPATCHER'   => :dispatcher,
    'NEW_RELIC_FRAMEWORK'   => :framework,
    'NEWRELIC_FRAMEWORK'    => :framework
  }.each do |key, val|
    self[val] = ENV[key].intern if ENV[key]
  end

  boolean_map = {
    'NEWRELIC_ENABLE' => :agent_enabled
  }.each do |key, val|
    if ENV[key].to_s =~ /false|off|no/i
      self[val] = false
    elsif ENV[key] != nil
      self[val] = true
    end
  end

  if ENV['NEW_RELIC_LOG']
    if ENV['NEW_RELIC_LOG'].upcase == 'STDOUT'
      self[:log_file_path] = self[:log_file_name] = 'STDOUT'
    else
      self[:log_file_path] = File.dirname(ENV['NEW_RELIC_LOG'])
      self[:log_file_name] = File.basename(ENV['NEW_RELIC_LOG'])
    end
  end
end