Class: ScoutApm::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/config.rb

Constant Summary collapse

DEFAULTS =
{
    'host'      => 'https://checkin.scoutapp.com',
    'direct_host' => 'https://apm.scoutapp.com',
    'log_level' => 'info',
    'uri_reporting' => 'full_path',
    'report_format' => 'json',
    'disabled_instruments' => [],
    'enable_background_jobs' => true,
    'ignore_traces' => [],
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config_path = nil) ⇒ Config

Returns a new instance of Config.



36
37
38
# File 'lib/scout_apm/config.rb', line 36

def initialize(config_path = nil)
  @config_path = config_path
end

Instance Method Details

#config_file_exists?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/scout_apm/config.rb', line 40

def config_file_exists?
  File.exist?(config_path)
end

#value(key, env_only = false) ⇒ Object

Fetch a config value. It first attempts to fetch an ENV var prefixed with ‘SCOUT_’, then from the settings file.

If you set env_only, then it will not attempt to read the config file at all, and only read off the ENV var this is useful to break a loop during boot, where we needed an option to set the application root.



51
52
53
54
55
56
57
58
59
# File 'lib/scout_apm/config.rb', line 51

def value(key, env_only=false)
  value = if env_only
            ENV['SCOUT_' + key.upcase]
          else
            ENV['SCOUT_' + key.upcase] || setting(key)
          end

  value.to_s.strip.length.zero? ? nil : value
end