Class: NetuitiveRailsAgent::ConfigManager
- Inherits:
-
Object
- Object
- NetuitiveRailsAgent::ConfigManager
- Defined in:
- lib/netuitive_rails_agent/config_manager.rb
Class Attribute Summary collapse
-
.action_controller_enabled ⇒ Object
Returns the value of attribute action_controller_enabled.
-
.action_controller_whitelist ⇒ Object
Returns the value of attribute action_controller_whitelist.
-
.action_errors_enabled ⇒ Object
Returns the value of attribute action_errors_enabled.
-
.action_mailer_enabled ⇒ Object
Returns the value of attribute action_mailer_enabled.
-
.action_view_enabled ⇒ Object
Returns the value of attribute action_view_enabled.
-
.active_job_enabled ⇒ Object
Returns the value of attribute active_job_enabled.
-
.active_record_enabled ⇒ Object
Returns the value of attribute active_record_enabled.
-
.active_support_enabled ⇒ Object
Returns the value of attribute active_support_enabled.
-
.capture_errors ⇒ Object
Returns the value of attribute capture_errors.
-
.data ⇒ Object
Returns the value of attribute data.
-
.gc_enabled ⇒ Object
Returns the value of attribute gc_enabled.
-
.ignored_errors ⇒ Object
Returns the value of attribute ignored_errors.
-
.object_space_enabled ⇒ Object
Returns the value of attribute object_space_enabled.
-
.queue_time_divisor ⇒ Object
Returns the value of attribute queue_time_divisor.
-
.request_wrapper_enabled ⇒ Object
Returns the value of attribute request_wrapper_enabled.
-
.sidekiq_enabled ⇒ Object
Returns the value of attribute sidekiq_enabled.
Class Method Summary collapse
- .boolean_property(name, var) ⇒ Object
- .float_property(name, var) ⇒ Object
- .load_config ⇒ Object
- .property(name, var, default = nil) ⇒ Object
- .read_config ⇒ Object
- .string_list_property(name, var) ⇒ Object
Class Attribute Details
.action_controller_enabled ⇒ Object
Returns the value of attribute action_controller_enabled.
12 13 14 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 12 def action_controller_enabled @action_controller_enabled end |
.action_controller_whitelist ⇒ Object
Returns the value of attribute action_controller_whitelist.
32 33 34 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 32 def action_controller_whitelist @action_controller_whitelist end |
.action_errors_enabled ⇒ Object
Returns the value of attribute action_errors_enabled.
26 27 28 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 26 def action_errors_enabled @action_errors_enabled end |
.action_mailer_enabled ⇒ Object
Returns the value of attribute action_mailer_enabled.
18 19 20 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 18 def action_mailer_enabled @action_mailer_enabled end |
.action_view_enabled ⇒ Object
Returns the value of attribute action_view_enabled.
16 17 18 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 16 def action_view_enabled @action_view_enabled end |
.active_job_enabled ⇒ Object
Returns the value of attribute active_job_enabled.
22 23 24 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 22 def active_job_enabled @active_job_enabled end |
.active_record_enabled ⇒ Object
Returns the value of attribute active_record_enabled.
14 15 16 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 14 def active_record_enabled @active_record_enabled end |
.active_support_enabled ⇒ Object
Returns the value of attribute active_support_enabled.
20 21 22 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 20 def active_support_enabled @active_support_enabled end |
.capture_errors ⇒ Object
Returns the value of attribute capture_errors.
4 5 6 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 4 def capture_errors @capture_errors end |
.data ⇒ Object
Returns the value of attribute data.
34 35 36 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 34 def data @data end |
.gc_enabled ⇒ Object
Returns the value of attribute gc_enabled.
28 29 30 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 28 def gc_enabled @gc_enabled end |
.ignored_errors ⇒ Object
Returns the value of attribute ignored_errors.
6 7 8 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 6 def ignored_errors @ignored_errors end |
.object_space_enabled ⇒ Object
Returns the value of attribute object_space_enabled.
30 31 32 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 30 def object_space_enabled @object_space_enabled end |
.queue_time_divisor ⇒ Object
Returns the value of attribute queue_time_divisor.
8 9 10 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 8 def queue_time_divisor @queue_time_divisor end |
.request_wrapper_enabled ⇒ Object
Returns the value of attribute request_wrapper_enabled.
24 25 26 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 24 def request_wrapper_enabled @request_wrapper_enabled end |
.sidekiq_enabled ⇒ Object
Returns the value of attribute sidekiq_enabled.
10 11 12 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 10 def sidekiq_enabled @sidekiq_enabled end |
Class Method Details
.boolean_property(name, var) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# 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) ⇒ Object
54 55 56 57 58 59 60 61 |
# 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 ⇒ Object
75 76 77 78 |
# File 'lib/netuitive_rails_agent/config_manager.rb', line 75 def load_config gem_root = File.('../../..', __FILE__) @data = YAML.load_file "#{gem_root}/config/agent.yml" end |
.property(name, var, default = nil) ⇒ Object
36 37 38 39 40 41 |
# 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 ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# 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 |