Class: ScoutApm::Config

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

Constant Summary collapse

DEFAULTS =
{
    'host'      => 'https://checkin.scoutapp.com',
    'log_level' => 'info',
    'stackprof_interval' => 20000, # microseconds, 1000 = 1 millisecond, so 20k == 20 milliseconds
    'uri_reporting' => 'full_path'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config_path = nil) ⇒ Config

Returns a new instance of Config.



30
31
32
# File 'lib/scout_apm/config.rb', line 30

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

Instance Method Details

#config_file_exists?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/scout_apm/config.rb', line 34

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.



45
46
47
48
49
50
51
52
53
# File 'lib/scout_apm/config.rb', line 45

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