Module: NewRelic::Control::Configuration
- Included in:
- NewRelic::Control
- Defined in:
- lib/new_relic/control/configuration.rb
Overview
used to contain methods to look up settings from the configuration located in newrelic.yml
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #apdex_t ⇒ Object
- #app_names ⇒ Object
-
#browser_monitoring_auto_instrument? ⇒ Boolean
whether we should install the NewRelic::Rack::BrowserMonitoring middleware automatically on Rails applications.
- #capture_params ⇒ Object
-
#developer_mode? ⇒ Boolean
True if we are capturing data and displaying in /newrelic.
- #disable_backtrace_cleanup? ⇒ Boolean
- #disable_serialization=(b) ⇒ Object
- #disable_serialization? ⇒ Boolean
- #dispatcher ⇒ Object
- #dispatcher_instance_id ⇒ Object
- #fetch(key, default = nil) ⇒ Object
- #has_slow_sql_config? ⇒ Boolean
- #license_key ⇒ Object
- #log_file_path ⇒ Object
- #merge_defaults(settings_hash) ⇒ Object
-
#merge_options(options, hash = self) ⇒ Object
Merge the given options into the config options.
- #merge_server_side_config(data) ⇒ Object
-
#monitor_mode? ⇒ Boolean
True if we are sending data to the server, monitoring production.
- #multi_threaded? ⇒ Boolean
-
#post_size_limit ⇒ Object
defaults to 2MiB.
- #remove_server_controlled_configs ⇒ Object
-
#send_data_on_exit ⇒ Object
Configuration option of the same name to indicate that we should flush data to the server on exiting.
- #settings ⇒ Object
-
#sync_startup ⇒ Object
Configuration option of the same name to indicate that we should connect to New Relic synchronously on startup.
- #use_ssl? ⇒ Boolean
-
#use_textmate? ⇒ Boolean
True if we should view files in textmate.
- #validate_seed ⇒ Object
- #validate_token ⇒ Object
-
#verify_certificate? ⇒ Boolean
only verify certificates if you’re very sure you want this level of security, it includes possibly app-crashing dns lookups every connection to the server.
Instance Method Details
#[](key) ⇒ Object
74 75 76 |
# File 'lib/new_relic/control/configuration.rb', line 74 def [](key) fetch(key) end |
#[]=(key, value) ⇒ Object
78 79 80 |
# File 'lib/new_relic/control/configuration.rb', line 78 def []=(key, value) settings[key] = value end |
#apdex_t ⇒ Object
86 87 88 89 |
# File 'lib/new_relic/control/configuration.rb', line 86 def apdex_t # Always initialized with a default @apdex_t_float ||= fetch('apdex_t').to_f end |
#app_names ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/new_relic/control/configuration.rb', line 159 def app_names case self['app_name'] when Array then self['app_name'] when String then self['app_name'].split(';') else [ env ] end end |
#browser_monitoring_auto_instrument? ⇒ Boolean
whether we should install the NewRelic::Rack::BrowserMonitoring middleware automatically on Rails applications
113 114 115 |
# File 'lib/new_relic/control/configuration.rb', line 113 def browser_monitoring_auto_instrument? fetch('browser_monitoring', {}).fetch('auto_instrument', true) end |
#capture_params ⇒ Object
96 97 98 |
# File 'lib/new_relic/control/configuration.rb', line 96 def capture_params fetch('capture_params') end |
#developer_mode? ⇒ Boolean
True if we are capturing data and displaying in /newrelic
106 107 108 |
# File 'lib/new_relic/control/configuration.rb', line 106 def developer_mode? fetch('developer_mode', fetch('developer')) end |
#disable_backtrace_cleanup? ⇒ Boolean
196 197 198 |
# File 'lib/new_relic/control/configuration.rb', line 196 def disable_backtrace_cleanup? fetch('disable_backtrace_cleanup') end |
#disable_serialization=(b) ⇒ Object
124 125 126 |
# File 'lib/new_relic/control/configuration.rb', line 124 def disable_serialization=(b) self['disable_serialization'] = b end |
#disable_serialization? ⇒ Boolean
121 122 123 |
# File 'lib/new_relic/control/configuration.rb', line 121 def disable_serialization? fetch('disable_serialization', !DependencyDetection.installed?(:resque)) end |
#dispatcher ⇒ Object
156 157 158 |
# File 'lib/new_relic/control/configuration.rb', line 156 def dispatcher (self['dispatcher'] && self['dispatcher'].to_sym) || @local_env.dispatcher end |
#dispatcher_instance_id ⇒ Object
152 153 154 |
# File 'lib/new_relic/control/configuration.rb', line 152 def dispatcher_instance_id self['dispatcher_instance_id'] || @local_env.dispatcher_instance_id end |
#fetch(key, default = nil) ⇒ Object
82 83 84 |
# File 'lib/new_relic/control/configuration.rb', line 82 def fetch(key, default=nil) settings.fetch(key, default) end |
#has_slow_sql_config? ⇒ Boolean
200 201 202 |
# File 'lib/new_relic/control/configuration.rb', line 200 def has_slow_sql_config? self['slow_sql'] && self['slow_sql'].has_key?('enabled') end |
#license_key ⇒ Object
91 92 93 94 |
# File 'lib/new_relic/control/configuration.rb', line 91 def license_key env_setting = ENV['NEW_RELIC_LICENSE_KEY'] || ENV['NEWRELIC_LICENSE_KEY'] fetch('license_key', env_setting) end |
#log_file_path ⇒ Object
178 179 180 |
# File 'lib/new_relic/control/configuration.rb', line 178 def log_file_path fetch('log_file_path', 'log/') end |
#merge_defaults(settings_hash) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/new_relic/control/configuration.rb', line 23 def merge_defaults(settings_hash) s = { 'host' => 'collector.newrelic.com', 'ssl' => false, 'log_level' => 'info', 'apdex_t' => 0.5 } s.merge! settings_hash if settings_hash # monitor_daemons replaced with agent_enabled s['agent_enabled'] = s.delete('monitor_daemons') if s['agent_enabled'].nil? && s.include?('monitor_daemons') s end |
#merge_options(options, hash = self) ⇒ Object
Merge the given options into the config options. They might be a nested hash
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/new_relic/control/configuration.rb', line 38 def (, hash=self) .each do |key, val| case when key == :config then next when val.is_a?(Hash) (val, hash[key.to_s] ||= {}) when val.nil? hash.delete(key.to_s) else hash[key.to_s] = val end end end |
#merge_server_side_config(data) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/new_relic/control/configuration.rb', line 52 def merge_server_side_config(data) remove_server_controlled_configs config = Hash.new data.each_pair do |key, value| if key.include?('.') key = key.split('.') config[key.first] ||= Hash.new config[key.first][key[1]] = value else config[key] = value end end (config) end |
#monitor_mode? ⇒ Boolean
True if we are sending data to the server, monitoring production
101 102 103 |
# File 'lib/new_relic/control/configuration.rb', line 101 def monitor_mode? fetch('monitor_mode', fetch('enabled')) end |
#multi_threaded? ⇒ Boolean
117 118 119 |
# File 'lib/new_relic/control/configuration.rb', line 117 def multi_threaded? fetch('multi_threaded') end |
#post_size_limit ⇒ Object
defaults to 2MiB
134 135 136 |
# File 'lib/new_relic/control/configuration.rb', line 134 def post_size_limit fetch('post_size_limit', 2 * 1024 * 1024) end |
#remove_server_controlled_configs ⇒ Object
67 68 69 70 71 72 |
# File 'lib/new_relic/control/configuration.rb', line 67 def remove_server_controlled_configs settings.delete('transaction_tracer') settings.delete('slow_sql') settings.delete('error_collector') settings.delete('capture_params') end |
#send_data_on_exit ⇒ Object
Configuration option of the same name to indicate that we should flush data to the server on exiting. Defaults to true.
148 149 150 |
# File 'lib/new_relic/control/configuration.rb', line 148 def send_data_on_exit fetch('send_data_on_exit', true) end |
#settings ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/new_relic/control/configuration.rb', line 6 def settings unless @settings @settings = (@yaml && merge_defaults(@yaml[env])) || {} # At the time we bind the settings, we also need to run this little piece # of magic which allows someone to augment the id with the app name, necessary if self['multi_homed'] && app_names.size > 0 if @local_env.dispatcher_instance_id @local_env.dispatcher_instance_id << ":#{app_names.first}" else @local_env.dispatcher_instance_id = app_names.first end end end @settings end |
#sync_startup ⇒ Object
Configuration option of the same name to indicate that we should connect to New Relic synchronously on startup. This means when the agent is loaded it won’t return without trying to set up the server connection at least once which can make startup take longer. Defaults to false.
142 143 144 |
# File 'lib/new_relic/control/configuration.rb', line 142 def sync_startup fetch('sync_startup', false) end |
#use_ssl? ⇒ Boolean
173 174 175 176 |
# File 'lib/new_relic/control/configuration.rb', line 173 def use_ssl? @use_ssl = fetch('ssl', false) unless @use_ssl @use_ssl end |
#use_textmate? ⇒ Boolean
True if we should view files in textmate
129 130 131 |
# File 'lib/new_relic/control/configuration.rb', line 129 def use_textmate? fetch('textmate') end |
#validate_seed ⇒ Object
166 167 168 |
# File 'lib/new_relic/control/configuration.rb', line 166 def validate_seed self['validate_seed'] || ENV['NR_VALIDATE_SEED'] end |
#validate_token ⇒ Object
169 170 171 |
# File 'lib/new_relic/control/configuration.rb', line 169 def validate_token self['validate_token'] || ENV['NR_VALIDATE_TOKEN'] end |
#verify_certificate? ⇒ Boolean
only verify certificates if you’re very sure you want this level of security, it includes possibly app-crashing dns lookups every connection to the server
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/new_relic/control/configuration.rb', line 185 def verify_certificate? unless @verify_certificate unless use_ssl? @verify_certificate = false else @verify_certificate = fetch('verify_certificate', false) end end @verify_certificate end |