Class: OneApm::Configuration::YamlSource

Inherits:
Support::DottedHash show all
Defined in:
lib/one_apm/configuration/yaml_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::DottedHash

#inspect, symbolize, #to_hash

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
# File 'lib/one_apm/configuration/yaml_source.rb', line 13

def initialize(path, env)
  config = {}

  begin
    @file_path = validate_config_file_path(path)
    return unless @file_path

    OneApm::Manager.logger.info("Reading configuration from #{path} (#{Dir.pwd})")
    raw_file = if RUBY_VERSION >= '1.9.3'
      File.read(@file_path, :encoding => 'utf-8') 
    else
      File.read(@file_path)
    end
    erb_file = process_erb(raw_file)
    config   = process_yaml(erb_file, env, config, @file_path)
    add_notified!(config)
  rescue ScriptError, StandardError => e
    OneApm::Manager.logger.error("Failed to read or parse configuration file at #{path}", e)
  end

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

  super(config, true)
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



11
12
13
# File 'lib/one_apm/configuration/yaml_source.rb', line 11

def file_path
  @file_path
end