Class: NewRelic::Agent::Configuration::YamlSource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DottedHash

#inspect

Constructor Details

#initialize(path, env) ⇒ YamlSource

Returns a new instance of YamlSource.



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
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 9

def initialize(path, env)
  config = {}
  begin
    @file_path = File.expand_path(path)
    if !File.exists?(@file_path)
      NewRelic::Control.instance.log.error("Unable to load configuration from #{path}")
      return
    end

    file = File.read(@file_path)

    # Next two are for populating the newrelic.yml via erb binding, necessary
    # when using the default newrelic.yml file
    generated_for_user = ''
    license_key = ''

    erb = ERB.new(file).result(binding)
    config = merge!(YAML.load(erb)[env] || {})
  rescue ScriptError, StandardError => e
    NewRelic::Control.instance.log.warn("Unable to read configuration file: #{e}")
  end

  if config['transaction_tracer'] &&
      config['transaction_tracer']['transaction_threshold'] =~ /apdex_f/i
    # when value is "apdex_f" remove the config and defer to default
    config['transaction_tracer'].delete('transaction_threshold')
  end

  booleanify_values(config, 'agent_enabled', 'enabled', 'monitor_daemons')

  super(config)
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



7
8
9
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 7

def file_path
  @file_path
end