Class: NewRelic::Agent::Configuration::YamlSource
- Inherits:
-
DottedHash
- Object
- Hash
- DottedHash
- NewRelic::Agent::Configuration::YamlSource
- Defined in:
- lib/new_relic/agent/configuration/yaml_source.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
Instance Method Summary collapse
-
#initialize(path, env) ⇒ YamlSource
constructor
A new instance of YamlSource.
Methods inherited from DottedHash
Constructor Details
#initialize(path, env) ⇒ YamlSource
Returns a new instance of YamlSource.
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 46 47 48 49 50 |
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 13 def initialize(path, env) ::NewRelic::Agent.logger.info("Reading configuration from #{path}") config = {} begin @file_path = File.(path) if !File.exists?(@file_path) ::NewRelic::Agent.logger.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) confighash = with_yaml_engine { YAML.load(erb) } ::NewRelic::Agent.logger.error("Config (#{path}) doesn't include a '#{env}' environment!") unless confighash.key?(env) config = merge!(confighash[env] || {}) rescue ScriptError, StandardError => e ::NewRelic::Agent.logger.error("Unable to read configuration file #{path}: #{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_path ⇒ Object
Returns the value of attribute file_path.
11 12 13 |
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 11 def file_path @file_path end |