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

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

Constant Summary collapse

CONFIG_WITH_HASH_VALUE =

These are configuration options that have a value of a Hash This is used in YamlSource#dot_flattened prevent flattening these values

%w[expected_messages ignore_messages]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DottedHash

#inspect, symbolize, #to_hash

Constructor Details

#initialize(path, env) ⇒ YamlSource

Returns a new instance of YamlSource.

[View source]

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

def initialize(path, env)
  @path = path
  config = {}
  @failures = []

  # These are needed in process_erb for populating the newrelic.yml via
  # erb binding, necessary when using the default newrelic.yml file. They
  # are defined as ivars instead of local variables to prevent
  # `assigned but unused variable` warnings when running with -W
  @generated_for_user = ''
  @license_key = ''

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

    ::NewRelic::Agent.logger.info("Reading configuration from #{path} (#{Dir.pwd})")
    raw_file = File.read(@file_path)
    erb_file = process_erb(raw_file)
    config = process_yaml(erb_file, env, config, @file_path)
  rescue ScriptError, StandardError => e
    NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::FAILED_TO_PARSE_CONFIG)
    log_failure("Failed to read or parse configuration file at #{path}", e)
  end

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

  super(config, true)
end

Instance Attribute Details

#failuresObject


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

def failures
  @failures
end

#file_pathObject


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

def file_path
  @file_path
end

#generated_for_userObject (readonly)


12
13
14
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 12

def generated_for_user
  @generated_for_user
end

#license_keyObject (readonly)


12
13
14
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 12

def license_key
  @license_key
end

Instance Method Details

#failed?Boolean

Returns:

[View source]

50
51
52
# File 'lib/new_relic/agent/configuration/yaml_source.rb', line 50

def failed?
  !@failures.empty?
end