class NetuitiveRailsAgent::ConfigManager

Attributes

action_controller_enabled[RW]
action_controller_whitelist[RW]
action_errors_enabled[RW]
action_mailer_enabled[RW]
action_view_enabled[RW]
active_job_enabled[RW]
active_record_enabled[RW]
active_support_enabled[RW]
capture_errors[RW]
data[RW]
gc_enabled[RW]
ignored_errors[RW]
object_space_enabled[RW]
queue_time_divisor[RW]
request_wrapper_enabled[RW]
sidekiq_enabled[RW]

Public Class Methods

boolean_property(name, var) click to toggle source
# File lib/netuitive_rails_agent/config_manager.rb, line 43
def boolean_property(name, var)
  prop = ENV[var].nil? ? nil : ENV[var].dup
  if prop.nil? || (prop == '')
    prop = data[name]
  else
    prop.strip!
    prop = prop.casecmp('true').zero?
  end
  prop
end
float_property(name, var) click to toggle source
# File lib/netuitive_rails_agent/config_manager.rb, line 54
def float_property(name, var)
  prop = ENV[var].nil? ? nil : ENV[var]
  if prop.nil? || (prop == '')
    data[name].to_f
  else
    prop.to_f
  end
end
load_config() click to toggle source
# File lib/netuitive_rails_agent/config_manager.rb, line 75
def load_config
  gem_root = File.expand_path('../../..', __FILE__)
  @data = YAML.load_file "#{gem_root}/config/agent.yml"
end
property(name, var, default = nil) click to toggle source
# File lib/netuitive_rails_agent/config_manager.rb, line 36
def property(name, var, default = nil)
  prop = ENV[var]
  prop = data[name] if prop.nil? || (prop == '')
  return prop unless prop.nil? || (prop == '')
  default
end
read_config() click to toggle source
# File lib/netuitive_rails_agent/config_manager.rb, line 80
def read_config
  debug_level_string = property('debugLevel', 'NETUITIVE_RAILS_DEBUG_LEVEL')
  NetuitiveRailsAgent::NetuitiveLogger.log.level = if debug_level_string == 'error'
                                                     Logger::ERROR
                                                   elsif debug_level_string == 'info'
                                                     Logger::INFO
                                                   elsif debug_level_string == 'debug'
                                                     Logger::DEBUG
                                                   else
                                                     Logger::ERROR
                                                   end

  @capture_errors = boolean_property('sendErrorEvents', 'NETUITIVE_RAILS_SEND_ERROR_EVENTS')
  @queue_time_divisor = float_property('queueTimeUnits', 'NETUITIVE_RAILS_QUEUE_TIME_UNITS')
  @ignored_errors = string_list_property('ignoredErrors', 'NETUITIVE_RAILS_IGNORED_ERRORS')
  @sidekiq_enabled = boolean_property('sidekiqEnabled', 'NETUITIVE_RAILS_SIDEKIQ_ENABLED')
  @action_controller_enabled = boolean_property('actionControllerEnabled', 'NETUITIVE_RAILS_ACTION_CONTROLLER_ENABLED')
  @active_record_enabled = boolean_property('activeRecordEnabled', 'NETUITIVE_RAILS_ACTIVE_RECORD_ENABLED')
  @action_view_enabled = boolean_property('actionViewEnabled', 'NETUITIVE_RAILS_ACTION_VIEW_ENABLED')
  @action_mailer_enabled = boolean_property('actionMailerEnabled', 'NETUITIVE_RAILS_ACTION_MAILER_ENABLED')
  @active_support_enabled = boolean_property('activeSupportEnabled', 'NETUITIVE_RAILS_ACTIVE_SUPPORT_ENABLED')
  @active_job_enabled = boolean_property('activeJobEnabled', 'NETUITIVE_RAILS_ACTIVE_JOB_ENABLED')
  @request_wrapper_enabled = boolean_property('requestWrapperEnabled', 'NETUITIVE_RAILS_REQUEST_WRAPPER_ENABLED')
  @action_errors_enabled = boolean_property('actionErrorsEnabled', 'NETUITIVE_RAILS_ACTION_ERRORS_ENABLED')
  @gc_enabled = boolean_property('gcEnabled', 'NETUITIVE_RAILS_GC_ENABLED')
  @object_space_enabled = boolean_property('objectSpaceEnabled', 'NETUITIVE_RAILS_OBJECT_SPACE_ENABLED')
  @action_controller_whitelist = property('actionControllerWhitelist', 'NETUITIVE_RAILS_ACTION_CONTROLLER_WHITELIST')

  NetuitiveRailsAgent::NetuitiveLogger.log.debug "read config file. Results:
    debugLevel: #{debug_level_string},
    capture_errors: #{capture_errors},
    ignored_errors: #{ignored_errors},
    queue_time_divisor: #{queue_time_divisor},
    sidekiq_enabled: #{sidekiq_enabled},
    action_controller_enabled: #{action_controller_enabled},
    active_record_enabled: #{active_record_enabled},
    action_view_enabled: #{action_view_enabled},
    action_mailer_enabled: #{action_mailer_enabled},
    active_support_enabled: #{active_support_enabled},
    active_job_enabled: #{active_job_enabled},
    request_wrapper_enabled: #{request_wrapper_enabled},
    action_errors_enabled: #{action_errors_enabled},
    gc_enabled: #{gc_enabled},
    object_space_enabled: #{object_space_enabled}
    action_controller_whitelist: #{action_controller_whitelist}"
end
string_list_property(name, var) click to toggle source
# File lib/netuitive_rails_agent/config_manager.rb, line 63
def string_list_property(name, var)
  list = []
  prop = ENV[var].nil? ? nil : ENV[var].dup
  if prop.nil? || (prop == '')
    list = data[name] if !data[name].nil? && data[name].is_a?(Array)
  else
    list = prop.split(',')
  end
  list.each(&:strip!) unless list.empty?
  list
end