Class: ScoutApm::Config
- Inherits:
-
Object
- Object
- ScoutApm::Config
- 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 }.freeze
Instance Method Summary collapse
-
#initialize(config_path = nil) ⇒ Config
constructor
A new instance of Config.
-
#value(key, env_only = false) ⇒ Object
Fetch a config value.
Constructor Details
#initialize(config_path = nil) ⇒ Config
Returns a new instance of Config.
27 28 29 |
# File 'lib/scout_apm/config.rb', line 27 def initialize(config_path = nil) @config_path = config_path end |
Instance Method Details
#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.
38 39 40 41 42 43 44 45 46 |
# File 'lib/scout_apm/config.rb', line 38 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 |