Class: Raven::Configuration
- Inherits:
-
Object
- Object
- Raven::Configuration
- Defined in:
- lib/raven/configuration.rb
Constant Summary collapse
- IGNORE_DEFAULT =
[ 'AbstractController::ActionNotFound', 'ActionController::InvalidAuthenticityToken', 'ActionController::RoutingError', 'ActionController::UnknownAction', 'ActiveRecord::RecordNotFound', 'CGI::Session::CookieStore::TamperedWithCookie', 'Mongoid::Errors::DocumentNotFound', 'Sinatra::NotFound' ].freeze
- DEFAULT_PROCESSORS =
Note the order - we have to remove circular references and bad characters before passing to other processors.
[ Raven::Processor::RemoveCircularReferences, Raven::Processor::UTF8Conversion, Raven::Processor::SanitizeData, Raven::Processor::Cookies, Raven::Processor::PostData, Raven::Processor::HTTPHeaders ].freeze
- LOG_PREFIX =
"** [Raven] ".freeze
Instance Attribute Summary collapse
-
#app_dirs_pattern ⇒ Object
Directories to be recognized as part of your app.
-
#async ⇒ Object
(also: #async?)
Provide an object that responds to ‘call` to send events asynchronously.
-
#context_lines ⇒ Object
Number of lines of code context to capture, or nil for none.
-
#current_environment ⇒ Object
RACK_ENV by default.
-
#encoding ⇒ Object
Encoding type for event bodies.
-
#environments ⇒ Object
Whitelist of environments that will send notifications to Sentry.
-
#errors ⇒ Object
readonly
Errors object - an Array that contains error messages.
-
#exclude_loggers ⇒ Object
Logger ‘progname’s to exclude from breadcrumbs.
-
#excluded_exceptions ⇒ Object
Array of exception classes that should never be sent.
-
#host ⇒ Object
DSN component - set automatically if DSN provided.
-
#http_adapter ⇒ Object
The Faraday adapter to be used.
-
#linecache ⇒ Object
You may provide your own LineCache for matching paths with source files.
-
#logger ⇒ Object
Logger used by Raven.
-
#open_timeout ⇒ Object
Timeout waiting for the Sentry server connection to open in seconds.
-
#path ⇒ Object
DSN component - set automatically if DSN provided.
-
#port ⇒ Object
DSN component - set automatically if DSN provided.
-
#processors ⇒ Object
Processors to run on data before sending upstream.
-
#project_id ⇒ Object
Project ID number to send to the Sentry server If you provide a DSN, this will be set automatically.
-
#project_root ⇒ Object
Project directory root for in_app detection.
-
#proxy ⇒ Object
Proxy information to pass to the HTTP adapter (via Faraday).
-
#public_key ⇒ Object
Public key for authentication with the Sentry server If you provide a DSN, this will be set automatically.
-
#rails_activesupport_breadcrumbs ⇒ Object
Turns on ActiveSupport breadcrumbs integration.
-
#rails_report_rescued_exceptions ⇒ Object
Rails catches exceptions in the ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions middlewares, depending on the environment.
-
#release ⇒ Object
Release tag to be passed with every event sent to Sentry.
-
#sanitize_credit_cards ⇒ Object
Boolean - sanitize values that look like credit card numbers.
-
#sanitize_fields ⇒ Object
By default, Sentry censors Hash values when their keys match things like “secret”, “password”, etc.
-
#sanitize_http_headers ⇒ Object
Sanitize additional HTTP headers - only Authorization is removed by default.
-
#scheme ⇒ Object
DSN component - set automatically if DSN provided.
-
#secret_key ⇒ Object
Secret key for authentication with the Sentry server If you provide a DSN, this will be set automatically.
-
#send_modules ⇒ Object
Include module versions in reports - boolean.
-
#server ⇒ Object
Simple server string - set this to the DSN found on your Sentry settings.
-
#server_name ⇒ Object
Returns the value of attribute server_name.
-
#should_capture ⇒ Object
Provide a configurable callback to determine event capture.
-
#silence_ready ⇒ Object
Silences ready message when true.
-
#ssl ⇒ Object
SSL settings passed directly to Faraday’s ssl option.
-
#ssl_ca_file ⇒ Object
The path to the SSL certificate file.
-
#ssl_verification ⇒ Object
Should the SSL certificate of the server be verified?.
-
#tags ⇒ Object
Default tags for events.
-
#timeout ⇒ Object
Timeout when waiting for the server to return data in seconds.
-
#transport_failure_callback ⇒ Object
Optional Proc, called when the Sentry server cannot be contacted for any reason E.g.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
- #capture_allowed?(message_or_exc = nil) ⇒ Boolean (also: #sending_allowed?)
- #detect_release ⇒ Object
- #error_messages ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/raven/configuration.rb', line 173 def initialize self.async = false self.context_lines = 3 self.current_environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default' self.encoding = 'gzip' self.environments = [] self.exclude_loggers = [] self.excluded_exceptions = IGNORE_DEFAULT.dup self.linecache = ::Raven::LineCache.new self.logger = ::Raven::Logger.new(STDOUT) self.open_timeout = 1 self.processors = DEFAULT_PROCESSORS.dup self.proxy = nil self. = false self.rails_report_rescued_exceptions = true self.release = detect_release self.sanitize_credit_cards = true self.sanitize_fields = [] self.sanitize_http_headers = [] self.send_modules = true self.server = ENV['SENTRY_DSN'] if ENV['SENTRY_DSN'] self.server_name = resolve_hostname self.should_capture = false self.ssl_verification = true self. = {} self.timeout = 2 self.transport_failure_callback = false end |
Instance Attribute Details
#app_dirs_pattern ⇒ Object
Directories to be recognized as part of your app. e.g. if you have an ‘engines` dir at the root of your project, you may want to set this to something like /(app|config|engines|lib)/
9 10 11 |
# File 'lib/raven/configuration.rb', line 9 def app_dirs_pattern @app_dirs_pattern end |
#async ⇒ Object Also known as: async?
Provide an object that responds to ‘call` to send events asynchronously. E.g.: lambda { |event| Thread.new { Raven.send_event(event) } }
13 14 15 |
# File 'lib/raven/configuration.rb', line 13 def async @async end |
#context_lines ⇒ Object
Number of lines of code context to capture, or nil for none
17 18 19 |
# File 'lib/raven/configuration.rb', line 17 def context_lines @context_lines end |
#current_environment ⇒ Object
RACK_ENV by default.
20 21 22 |
# File 'lib/raven/configuration.rb', line 20 def current_environment @current_environment end |
#encoding ⇒ Object
Encoding type for event bodies. Must be :json or :gzip.
23 24 25 |
# File 'lib/raven/configuration.rb', line 23 def encoding @encoding end |
#environments ⇒ Object
Whitelist of environments that will send notifications to Sentry. Array of Strings.
26 27 28 |
# File 'lib/raven/configuration.rb', line 26 def environments @environments end |
#errors ⇒ Object (readonly)
Errors object - an Array that contains error messages. See #
147 148 149 |
# File 'lib/raven/configuration.rb', line 147 def errors @errors end |
#exclude_loggers ⇒ Object
Logger ‘progname’s to exclude from breadcrumbs
29 30 31 |
# File 'lib/raven/configuration.rb', line 29 def exclude_loggers @exclude_loggers end |
#excluded_exceptions ⇒ Object
Array of exception classes that should never be sent. See IGNORE_DEFAULT. You should probably append to this rather than overwrite it.
33 34 35 |
# File 'lib/raven/configuration.rb', line 33 def excluded_exceptions @excluded_exceptions end |
#host ⇒ Object
DSN component - set automatically if DSN provided
36 37 38 |
# File 'lib/raven/configuration.rb', line 36 def host @host end |
#http_adapter ⇒ Object
The Faraday adapter to be used. Will default to Net::HTTP when not set.
39 40 41 |
# File 'lib/raven/configuration.rb', line 39 def http_adapter @http_adapter end |
#linecache ⇒ Object
You may provide your own LineCache for matching paths with source files. This may be useful if you need to get source code from places other than the disk. See Raven::LineCache for the required interface you must implement.
44 45 46 |
# File 'lib/raven/configuration.rb', line 44 def linecache @linecache end |
#logger ⇒ Object
Logger used by Raven. In Rails, this is the Rails logger, otherwise Raven provides its own Raven::Logger.
48 49 50 |
# File 'lib/raven/configuration.rb', line 48 def logger @logger end |
#open_timeout ⇒ Object
Timeout waiting for the Sentry server connection to open in seconds
51 52 53 |
# File 'lib/raven/configuration.rb', line 51 def open_timeout @open_timeout end |
#path ⇒ Object
DSN component - set automatically if DSN provided
54 55 56 |
# File 'lib/raven/configuration.rb', line 54 def path @path end |
#port ⇒ Object
DSN component - set automatically if DSN provided
57 58 59 |
# File 'lib/raven/configuration.rb', line 57 def port @port end |
#processors ⇒ Object
Processors to run on data before sending upstream. See DEFAULT_PROCESSORS. You should probably append to this rather than overwrite it.
61 62 63 |
# File 'lib/raven/configuration.rb', line 61 def processors @processors end |
#project_id ⇒ Object
Project ID number to send to the Sentry server If you provide a DSN, this will be set automatically.
65 66 67 |
# File 'lib/raven/configuration.rb', line 65 def project_id @project_id end |
#project_root ⇒ Object
Project directory root for in_app detection. Could be Rails root, etc. Set automatically for Rails.
69 70 71 |
# File 'lib/raven/configuration.rb', line 69 def project_root @project_root end |
#proxy ⇒ Object
Proxy information to pass to the HTTP adapter (via Faraday)
72 73 74 |
# File 'lib/raven/configuration.rb', line 72 def proxy @proxy end |
#public_key ⇒ Object
Public key for authentication with the Sentry server If you provide a DSN, this will be set automatically.
76 77 78 |
# File 'lib/raven/configuration.rb', line 76 def public_key @public_key end |
#rails_activesupport_breadcrumbs ⇒ Object
Turns on ActiveSupport breadcrumbs integration
79 80 81 |
# File 'lib/raven/configuration.rb', line 79 def @rails_activesupport_breadcrumbs end |
#rails_report_rescued_exceptions ⇒ Object
Rails catches exceptions in the ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions middlewares, depending on the environment. When ‘rails_report_rescued_exceptions` is true (it is by default), Raven will report exceptions even when they are rescued by these middlewares.
85 86 87 |
# File 'lib/raven/configuration.rb', line 85 def rails_report_rescued_exceptions @rails_report_rescued_exceptions end |
#release ⇒ Object
Release tag to be passed with every event sent to Sentry. We automatically try to set this to a git SHA or Capistrano release.
89 90 91 |
# File 'lib/raven/configuration.rb', line 89 def release @release end |
#sanitize_credit_cards ⇒ Object
Boolean - sanitize values that look like credit card numbers
92 93 94 |
# File 'lib/raven/configuration.rb', line 92 def sanitize_credit_cards @sanitize_credit_cards end |
#sanitize_fields ⇒ Object
By default, Sentry censors Hash values when their keys match things like “secret”, “password”, etc. Provide an array of Strings that, when matched in a hash key, will be censored and not sent to Sentry.
97 98 99 |
# File 'lib/raven/configuration.rb', line 97 def sanitize_fields @sanitize_fields end |
#sanitize_http_headers ⇒ Object
Sanitize additional HTTP headers - only Authorization is removed by default.
100 101 102 |
# File 'lib/raven/configuration.rb', line 100 def sanitize_http_headers @sanitize_http_headers end |
#scheme ⇒ Object
DSN component - set automatically if DSN provided. Otherwise, can be one of “http”, “https”, or “dummy”
104 105 106 |
# File 'lib/raven/configuration.rb', line 104 def scheme @scheme end |
#secret_key ⇒ Object
Secret key for authentication with the Sentry server If you provide a DSN, this will be set automatically.
108 109 110 |
# File 'lib/raven/configuration.rb', line 108 def secret_key @secret_key end |
#send_modules ⇒ Object
Include module versions in reports - boolean.
111 112 113 |
# File 'lib/raven/configuration.rb', line 111 def send_modules @send_modules end |
#server ⇒ Object
Simple server string - set this to the DSN found on your Sentry settings.
114 115 116 |
# File 'lib/raven/configuration.rb', line 114 def server @server end |
#server_name ⇒ Object
Returns the value of attribute server_name.
116 117 118 |
# File 'lib/raven/configuration.rb', line 116 def server_name @server_name end |
#should_capture ⇒ Object
Provide a configurable callback to determine event capture. Note that the object passed into the block will be a String (messages) or an exception. e.g. lambda { |exc_or_msg| exc_or_msg.some_attr == false }
122 123 124 |
# File 'lib/raven/configuration.rb', line 122 def should_capture @should_capture end |
#silence_ready ⇒ Object
Silences ready message when true.
125 126 127 |
# File 'lib/raven/configuration.rb', line 125 def silence_ready @silence_ready end |
#ssl ⇒ Object
SSL settings passed directly to Faraday’s ssl option
128 129 130 |
# File 'lib/raven/configuration.rb', line 128 def ssl @ssl end |
#ssl_ca_file ⇒ Object
The path to the SSL certificate file
131 132 133 |
# File 'lib/raven/configuration.rb', line 131 def ssl_ca_file @ssl_ca_file end |
#ssl_verification ⇒ Object
Should the SSL certificate of the server be verified?
134 135 136 |
# File 'lib/raven/configuration.rb', line 134 def ssl_verification @ssl_verification end |
#tags ⇒ Object
Default tags for events. Hash.
137 138 139 |
# File 'lib/raven/configuration.rb', line 137 def @tags end |
#timeout ⇒ Object
Timeout when waiting for the server to return data in seconds.
140 141 142 |
# File 'lib/raven/configuration.rb', line 140 def timeout @timeout end |
#transport_failure_callback ⇒ Object
Optional Proc, called when the Sentry server cannot be contacted for any reason E.g. lambda { |event| Thread.new { MyJobProcessor.send_email(event) } }
144 145 146 |
# File 'lib/raven/configuration.rb', line 144 def transport_failure_callback @transport_failure_callback end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
254 255 256 |
# File 'lib/raven/configuration.rb', line 254 def [](option) public_send(option) end |
#capture_allowed?(message_or_exc = nil) ⇒ Boolean Also known as: sending_allowed?
262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/raven/configuration.rb', line 262 def capture_allowed?( = nil) @errors = [] @errors = valid? + capture_in_current_environment? + capture_allowed_by_callback?() if @errors.any? false else true end end |
#detect_release ⇒ Object
285 286 287 288 289 |
# File 'lib/raven/configuration.rb', line 285 def detect_release detect_release_from_git || detect_release_from_capistrano || detect_release_from_heroku end |
#error_messages ⇒ Object
276 277 278 |
# File 'lib/raven/configuration.rb', line 276 def errors.join(", ") end |