Class: Airbrake::Configuration
- Inherits:
-
Object
- Object
- Airbrake::Configuration
- Defined in:
- lib/airbrake/configuration.rb
Overview
Used to set up and modify settings for the notifier.
Constant Summary collapse
- OPTIONS =
[:api_key, :backtrace_filters, :development_environments, :development_lookup, :environment_name, :host, :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters, :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version, :params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain, :framework, :user_information, :rescue_rake_exceptions].freeze
- DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
- DEFAULT_BACKTRACE_FILTERS =
[ lambda { |line| if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != '' line.sub(/#{Airbrake.configuration.project_root}/, "[PROJECT_ROOT]") else line end }, lambda { |line| line.gsub(/^\.\//, "") }, lambda { |line| if defined?(Gem) Gem.path.inject(line) do |line, path| line.gsub(/#{path}/, "[GEM_ROOT]") end end }, lambda { |line| line if line !~ %r{lib/airbrake} } ].freeze
- IGNORE_DEFAULT =
['ActiveRecord::RecordNotFound', 'ActionController::RoutingError', 'ActionController::InvalidAuthenticityToken', 'CGI::Session::CookieStore::TamperedWithCookie', 'ActionController::UnknownAction', 'AbstractController::ActionNotFound']
Instance Attribute Summary collapse
-
#api_key ⇒ Object
The API key for your project, found on the project edit form.
-
#backtrace_filters ⇒ Object
readonly
A list of filters for cleaning and pruning the backtrace.
-
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
-
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors,false
otherwise. -
#environment_name ⇒ Object
The name of the environment the application is running in.
-
#framework ⇒ Object
The framework Airbrake is configured to use.
-
#host ⇒ Object
The host to connect to (defaults to airbrake.io).
-
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
-
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
-
#ignore ⇒ Object
readonly
A list of exception classes to ignore.
-
#ignore_by_filters ⇒ Object
readonly
A list of filters for ignoring exceptions.
-
#ignore_user_agent ⇒ Object
readonly
A list of user agents that are being ignored.
-
#logger ⇒ Object
The logger used by Airbrake.
-
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “Airbrake Notifier”).
-
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications.
-
#notifier_version ⇒ Object
The version of the notifier library being used to send notifications (such as “1.0.2”).
-
#params_filters ⇒ Object
readonly
A list of parameters that should be filtered out of what is sent to Airbrake.
-
#port ⇒ Object
The port on which your Airbrake server runs (defaults to 443 for secure connections, 80 for insecure connections).
-
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT.
-
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy).
-
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy).
-
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy).
-
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy).
-
#rescue_rake_exceptions ⇒ Object
Should Airbrake catch exceptions from Rake tasks? (boolean or nil; set to nil to catch exceptions when rake isn’t running from a terminal; default is nil).
-
#secure ⇒ Object
(also: #secure?)
true
for https connections,false
for http connections. -
#use_system_ssl_cert_chain ⇒ Object
(also: #use_system_ssl_cert_chain?)
true
to use whatever CAs OpenSSL has installed on your system. -
#user_information ⇒ Object
The text that the placeholder is replaced with.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
- #ca_bundle_path ⇒ Object
- #environment_filters ⇒ Object
-
#filter_backtrace(&block) {|line| ... } ⇒ Object
Takes a block and adds it to the list of backtrace filters.
-
#ignore_by_filter(&block) {|data| ... } ⇒ Object
Takes a block and adds it to the list of ignore filters.
-
#ignore_only=(names) ⇒ Object
Overrides the list of default ignored errors.
-
#ignore_user_agent_only=(names) ⇒ Object
Overrides the list of default ignored user agents.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #js_notifier=(*args) ⇒ Object
- #local_cert_path ⇒ Object
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. - #protocol ⇒ Object
-
#public? ⇒ Boolean
Determines if the notifier will send notices.
-
#to_hash ⇒ Object
Returns a hash of all configurable options.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/airbrake/configuration.rb', line 128 def initialize @secure = false @use_system_ssl_cert_chain= false @host = 'airbrake.io' @http_open_timeout = 2 @http_read_timeout = 5 @params_filters = DEFAULT_PARAMS_FILTERS.dup @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup @ignore_by_filters = [] @ignore = IGNORE_DEFAULT.dup @ignore_user_agent = [] @development_environments = %w(development test cucumber) @development_lookup = true @notifier_name = 'Airbrake Notifier' @notifier_version = VERSION @notifier_url = 'http://airbrake.io' @framework = 'Standalone' @user_information = 'Airbrake Error {{error_id}}' @rescue_rake_exceptions = nil end |
Instance Attribute Details
#api_key ⇒ Object
The API key for your project, found on the project edit form.
14 15 16 |
# File 'lib/airbrake/configuration.rb', line 14 def api_key @api_key end |
#backtrace_filters ⇒ Object (readonly)
A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
52 53 54 |
# File 'lib/airbrake/configuration.rb', line 52 def backtrace_filters @backtrace_filters end |
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
64 65 66 |
# File 'lib/airbrake/configuration.rb', line 64 def development_environments @development_environments end |
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors, false
otherwise.
67 68 69 |
# File 'lib/airbrake/configuration.rb', line 67 def development_lookup @development_lookup end |
#environment_name ⇒ Object
The name of the environment the application is running in
70 71 72 |
# File 'lib/airbrake/configuration.rb', line 70 def environment_name @environment_name end |
#framework ⇒ Object
The framework Airbrake is configured to use
91 92 93 |
# File 'lib/airbrake/configuration.rb', line 91 def framework @framework end |
#host ⇒ Object
The host to connect to (defaults to airbrake.io).
17 18 19 |
# File 'lib/airbrake/configuration.rb', line 17 def host @host end |
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
30 31 32 |
# File 'lib/airbrake/configuration.rb', line 30 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
33 34 35 |
# File 'lib/airbrake/configuration.rb', line 33 def http_read_timeout @http_read_timeout end |
#ignore ⇒ Object (readonly)
A list of exception classes to ignore. The array can be appended to.
58 59 60 |
# File 'lib/airbrake/configuration.rb', line 58 def ignore @ignore end |
#ignore_by_filters ⇒ Object (readonly)
A list of filters for ignoring exceptions. See #ignore_by_filter.
55 56 57 |
# File 'lib/airbrake/configuration.rb', line 55 def ignore_by_filters @ignore_by_filters end |
#ignore_user_agent ⇒ Object (readonly)
A list of user agents that are being ignored. The array can be appended to.
61 62 63 |
# File 'lib/airbrake/configuration.rb', line 61 def ignore_user_agent @ignore_user_agent end |
#logger ⇒ Object
The logger used by Airbrake
85 86 87 |
# File 'lib/airbrake/configuration.rb', line 85 def logger @logger end |
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “Airbrake Notifier”)
76 77 78 |
# File 'lib/airbrake/configuration.rb', line 76 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications
82 83 84 |
# File 'lib/airbrake/configuration.rb', line 82 def notifier_url @notifier_url end |
#notifier_version ⇒ Object
The version of the notifier library being used to send notifications (such as “1.0.2”)
79 80 81 |
# File 'lib/airbrake/configuration.rb', line 79 def notifier_version @notifier_version end |
#params_filters ⇒ Object (readonly)
A list of parameters that should be filtered out of what is sent to Airbrake. By default, all “password” attributes will have their contents replaced.
49 50 51 |
# File 'lib/airbrake/configuration.rb', line 49 def params_filters @params_filters end |
#port ⇒ Object
The port on which your Airbrake server runs (defaults to 443 for secure connections, 80 for insecure connections).
21 22 23 |
# File 'lib/airbrake/configuration.rb', line 21 def port @port end |
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT
73 74 75 |
# File 'lib/airbrake/configuration.rb', line 73 def project_root @project_root end |
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy)
36 37 38 |
# File 'lib/airbrake/configuration.rb', line 36 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy)
45 46 47 |
# File 'lib/airbrake/configuration.rb', line 45 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy)
39 40 41 |
# File 'lib/airbrake/configuration.rb', line 39 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy)
42 43 44 |
# File 'lib/airbrake/configuration.rb', line 42 def proxy_user @proxy_user end |
#rescue_rake_exceptions ⇒ Object
Should Airbrake catch exceptions from Rake tasks? (boolean or nil; set to nil to catch exceptions when rake isn’t running from a terminal; default is nil)
95 96 97 |
# File 'lib/airbrake/configuration.rb', line 95 def rescue_rake_exceptions @rescue_rake_exceptions end |
#secure ⇒ Object Also known as: secure?
true
for https connections, false
for http connections.
24 25 26 |
# File 'lib/airbrake/configuration.rb', line 24 def secure @secure end |
#use_system_ssl_cert_chain ⇒ Object Also known as: use_system_ssl_cert_chain?
true
to use whatever CAs OpenSSL has installed on your system. false
to use the ca-bundle.crt file included in Airbrake itself (reccomended and default)
27 28 29 |
# File 'lib/airbrake/configuration.rb', line 27 def use_system_ssl_cert_chain @use_system_ssl_cert_chain end |
#user_information ⇒ Object
The text that the placeholder is replaced with. {error_id} is the actual error number.
88 89 90 |
# File 'lib/airbrake/configuration.rb', line 88 def user_information @user_information end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
195 196 197 |
# File 'lib/airbrake/configuration.rb', line 195 def [](option) send(option) end |
#ca_bundle_path ⇒ Object
240 241 242 243 244 245 246 |
# File 'lib/airbrake/configuration.rb', line 240 def ca_bundle_path if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE) OpenSSL::X509::DEFAULT_CERT_FILE else local_cert_path # ca-bundle.crt built from source, see resources/README.md end end |
#environment_filters ⇒ Object
235 236 237 238 |
# File 'lib/airbrake/configuration.rb', line 235 def environment_filters warn 'config.environment_filters has been deprecated and has no effect.' [] end |
#filter_backtrace(&block) {|line| ... } ⇒ Object
Takes a block and adds it to the list of backtrace filters. When the filters run, the block will be handed each line of the backtrace and can modify it as necessary.
160 161 162 |
# File 'lib/airbrake/configuration.rb', line 160 def filter_backtrace(&block) self.backtrace_filters << block end |
#ignore_by_filter(&block) {|data| ... } ⇒ Object
Takes a block and adds it to the list of ignore filters. When the filters run, the block will be handed the exception.
174 175 176 |
# File 'lib/airbrake/configuration.rb', line 174 def ignore_by_filter(&block) self.ignore_by_filters << block end |
#ignore_only=(names) ⇒ Object
Overrides the list of default ignored errors.
181 182 183 |
# File 'lib/airbrake/configuration.rb', line 181 def ignore_only=(names) @ignore = [names].flatten end |
#ignore_user_agent_only=(names) ⇒ Object
Overrides the list of default ignored user agents
188 189 190 |
# File 'lib/airbrake/configuration.rb', line 188 def ignore_user_agent_only=(names) @ignore_user_agent = [names].flatten end |
#js_notifier=(*args) ⇒ Object
231 232 233 |
# File 'lib/airbrake/configuration.rb', line 231 def js_notifier=(*args) warn '[AIRBRAKE] config.js_notifier has been deprecated and has no effect. You should use <%= airbrake_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.' end |
#local_cert_path ⇒ Object
248 249 250 |
# File 'lib/airbrake/configuration.rb', line 248 def local_cert_path File.(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
209 210 211 |
# File 'lib/airbrake/configuration.rb', line 209 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/airbrake/configuration.rb', line 223 def protocol if secure? 'https' else 'http' end end |
#public? ⇒ Boolean
Determines if the notifier will send notices.
215 216 217 |
# File 'lib/airbrake/configuration.rb', line 215 def public? !development_environments.include?(environment_name) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
200 201 202 203 204 |
# File 'lib/airbrake/configuration.rb', line 200 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end |