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 =
[ Raven::Processor::Truncator, Raven::Processor::RemoveCircularReferences, Raven::Processor::UTF8Conversion, Raven::Processor::SanitizeData, Raven::Processor::Cookies, Raven::Processor::PostData, ].freeze
Instance Attribute Summary collapse
-
#app_dirs_pattern ⇒ Object
Directories to be recognized as part of your app.
-
#async ⇒ Object
(also: #async?)
Optional Proc to be used to send events asynchronously.
-
#catch_debugged_exceptions ⇒ Object
Deprecated accessor.
-
#context_lines ⇒ Object
Number of lines of code context to capture, or nil for none.
-
#current_environment ⇒ Object
Returns the value of attribute current_environment.
-
#encoding ⇒ Object
Encoding type for event bodies.
-
#environments ⇒ Object
Whitelist of environments that will send notifications to Sentry.
-
#event_bytesize_limit ⇒ Object
Truncate any strings longer than this bytesize before sending.
-
#exclude_loggers ⇒ Object
Logger ‘progname’s to exclude from breadcrumbs.
-
#excluded_exceptions ⇒ Object
Which exceptions should never be sent.
-
#host ⇒ Object
Returns the value of attribute host.
-
#http_adapter ⇒ Object
The Faraday adapter to be used.
-
#json_adapter ⇒ Object
DEPRECATED: This option is now ignored as we use our own adapter.
-
#logger ⇒ Object
Logger to use internally.
-
#open_timeout ⇒ Object
Timeout waiting for the connection to open in seconds.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#processors ⇒ Object
Processors to run on data before sending upstream.
-
#project_id ⇒ Object
Project ID number to send to the Sentry server.
-
#project_root ⇒ Object
Project directory root.
-
#proxy ⇒ Object
Proxy information to pass to the HTTP adapter.
-
#public_key ⇒ Object
Public key for authentication with the Sentry server.
-
#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
Returns the value of attribute release.
-
#sanitize_credit_cards ⇒ Object
Sanitize values that look like credit card numbers.
-
#sanitize_fields ⇒ Object
additional fields to sanitize.
-
#scheme ⇒ Object
Accessors for the component parts of the DSN.
-
#secret_key ⇒ Object
Secret key for authentication with the Sentry server.
-
#send_modules ⇒ Object
Include module versions in reports?.
-
#server ⇒ Object
Simple server string (setter provided below).
-
#server_name ⇒ Object
Returns the value of attribute server_name.
-
#should_capture ⇒ Object
Provide a configurable callback to determine event capture.
-
#silence_ready ⇒ Object
Silence ready message.
-
#ssl ⇒ Object
SSl settings passed direactly 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.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
- #capture_allowed?(message_or_exc) ⇒ Boolean (also: #sending_allowed?)
- #capture_allowed_by_callback?(message_or_exc) ⇒ Boolean
- #capture_in_current_environment? ⇒ Boolean
- #detect_release ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #verify! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/raven/configuration.rb', line 141 def initialize self.server = ENV['SENTRY_DSN'] if ENV['SENTRY_DSN'] @context_lines = 3 self.current_environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default' self.send_modules = true self.excluded_exceptions = IGNORE_DEFAULT.dup self.processors = DEFAULT_PROCESSORS.dup self.ssl_verification = true self.encoding = 'gzip' self.timeout = 2 self.open_timeout = 1 self.proxy = nil self. = {} self.async = false self.rails_report_rescued_exceptions = true self. = false self.transport_failure_callback = false self.sanitize_fields = [] self.sanitize_credit_cards = true self.event_bytesize_limit = 8_000 self.environments = [] self.exclude_loggers = [] self.release = detect_release # Try to resolve the hostname to an FQDN, but fall back to whatever the load name is self.server_name = Socket.gethostname self.server_name = Socket.gethostbyname(hostname).first rescue server_name 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)/
93 94 95 |
# File 'lib/raven/configuration.rb', line 93 def app_dirs_pattern @app_dirs_pattern end |
#async ⇒ Object Also known as: async?
Optional Proc to be used to send events asynchronously.
85 86 87 |
# File 'lib/raven/configuration.rb', line 85 def async @async end |
#catch_debugged_exceptions ⇒ Object
Deprecated accessor
101 102 103 |
# File 'lib/raven/configuration.rb', line 101 def catch_debugged_exceptions @catch_debugged_exceptions end |
#context_lines ⇒ Object
Number of lines of code context to capture, or nil for none
37 38 39 |
# File 'lib/raven/configuration.rb', line 37 def context_lines @context_lines end |
#current_environment ⇒ Object
Returns the value of attribute current_environment.
69 70 71 |
# File 'lib/raven/configuration.rb', line 69 def current_environment @current_environment end |
#encoding ⇒ Object
Encoding type for event bodies
28 29 30 |
# File 'lib/raven/configuration.rb', line 28 def encoding @encoding end |
#environments ⇒ Object
Whitelist of environments that will send notifications to Sentry
40 41 42 |
# File 'lib/raven/configuration.rb', line 40 def environments @environments end |
#event_bytesize_limit ⇒ Object
Truncate any strings longer than this bytesize before sending
116 117 118 |
# File 'lib/raven/configuration.rb', line 116 def event_bytesize_limit @event_bytesize_limit end |
#exclude_loggers ⇒ Object
Logger ‘progname’s to exclude from breadcrumbs
119 120 121 |
# File 'lib/raven/configuration.rb', line 119 def exclude_loggers @exclude_loggers end |
#excluded_exceptions ⇒ Object
Which exceptions should never be sent
46 47 48 |
# File 'lib/raven/configuration.rb', line 46 def excluded_exceptions @excluded_exceptions end |
#host ⇒ Object
Returns the value of attribute host.
17 18 19 |
# File 'lib/raven/configuration.rb', line 17 def host @host end |
#http_adapter ⇒ Object
The Faraday adapter to be used. Will default to Net::HTTP when not set.
72 73 74 |
# File 'lib/raven/configuration.rb', line 72 def http_adapter @http_adapter end |
#json_adapter ⇒ Object
DEPRECATED: This option is now ignored as we use our own adapter.
79 80 81 |
# File 'lib/raven/configuration.rb', line 79 def json_adapter @json_adapter end |
#logger ⇒ Object
Logger to use internally
31 32 33 |
# File 'lib/raven/configuration.rb', line 31 def logger @logger end |
#open_timeout ⇒ Object
Timeout waiting for the connection to open in seconds
55 56 57 |
# File 'lib/raven/configuration.rb', line 55 def open_timeout @open_timeout end |
#path ⇒ Object
Returns the value of attribute path.
19 20 21 |
# File 'lib/raven/configuration.rb', line 19 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
18 19 20 |
# File 'lib/raven/configuration.rb', line 18 def port @port end |
#processors ⇒ Object
Processors to run on data before sending upstream
49 50 51 |
# File 'lib/raven/configuration.rb', line 49 def processors @processors end |
#project_id ⇒ Object
Project ID number to send to the Sentry server
22 23 24 |
# File 'lib/raven/configuration.rb', line 22 def project_id @project_id end |
#project_root ⇒ Object
Project directory root
25 26 27 |
# File 'lib/raven/configuration.rb', line 25 def project_root @project_root end |
#proxy ⇒ Object
Proxy information to pass to the HTTP adapter
67 68 69 |
# File 'lib/raven/configuration.rb', line 67 def proxy @proxy end |
#public_key ⇒ Object
Public key for authentication with the Sentry server
10 11 12 |
# File 'lib/raven/configuration.rb', line 10 def public_key @public_key end |
#rails_activesupport_breadcrumbs ⇒ Object
Turns on ActiveSupport breadcrumbs integration
104 105 106 |
# File 'lib/raven/configuration.rb', line 104 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.
99 100 101 |
# File 'lib/raven/configuration.rb', line 99 def rails_report_rescued_exceptions @rails_report_rescued_exceptions end |
#release ⇒ Object
Returns the value of attribute release.
76 77 78 |
# File 'lib/raven/configuration.rb', line 76 def release @release end |
#sanitize_credit_cards ⇒ Object
Sanitize values that look like credit card numbers
113 114 115 |
# File 'lib/raven/configuration.rb', line 113 def sanitize_credit_cards @sanitize_credit_cards end |
#sanitize_fields ⇒ Object
additional fields to sanitize
110 111 112 |
# File 'lib/raven/configuration.rb', line 110 def sanitize_fields @sanitize_fields end |
#scheme ⇒ Object
Accessors for the component parts of the DSN
16 17 18 |
# File 'lib/raven/configuration.rb', line 16 def scheme @scheme end |
#secret_key ⇒ Object
Secret key for authentication with the Sentry server
13 14 15 |
# File 'lib/raven/configuration.rb', line 13 def secret_key @secret_key end |
#send_modules ⇒ Object
Include module versions in reports?
43 44 45 |
# File 'lib/raven/configuration.rb', line 43 def send_modules @send_modules end |
#server ⇒ Object
Simple server string (setter provided below)
7 8 9 |
# File 'lib/raven/configuration.rb', line 7 def server @server end |
#server_name ⇒ Object
Returns the value of attribute server_name.
74 75 76 |
# File 'lib/raven/configuration.rb', line 74 def server_name @server_name end |
#should_capture ⇒ Object
Provide a configurable callback to determine event capture
107 108 109 |
# File 'lib/raven/configuration.rb', line 107 def should_capture @should_capture end |
#silence_ready ⇒ Object
Silence ready message
34 35 36 |
# File 'lib/raven/configuration.rb', line 34 def silence_ready @silence_ready end |
#ssl ⇒ Object
SSl settings passed direactly to faraday’s ssl option
64 65 66 |
# File 'lib/raven/configuration.rb', line 64 def ssl @ssl end |
#ssl_ca_file ⇒ Object
The path to the SSL certificate file
61 62 63 |
# File 'lib/raven/configuration.rb', line 61 def ssl_ca_file @ssl_ca_file end |
#ssl_verification ⇒ Object
Should the SSL certificate of the server be verified?
58 59 60 |
# File 'lib/raven/configuration.rb', line 58 def ssl_verification @ssl_verification end |
#tags ⇒ Object
Default tags for events
82 83 84 |
# File 'lib/raven/configuration.rb', line 82 def @tags end |
#timeout ⇒ Object
Timeout when waiting for the server to return data in seconds
52 53 54 |
# File 'lib/raven/configuration.rb', line 52 def timeout @timeout end |
#transport_failure_callback ⇒ Object
Optional Proc, called when the Sentry server cannot be contacted for any reason
88 89 90 |
# File 'lib/raven/configuration.rb', line 88 def transport_failure_callback @transport_failure_callback end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
215 216 217 |
# File 'lib/raven/configuration.rb', line 215 def [](option) send(option) end |
#capture_allowed?(message_or_exc) ⇒ Boolean Also known as: sending_allowed?
223 224 225 226 |
# File 'lib/raven/configuration.rb', line 223 def capture_allowed?() capture_in_current_environment? && capture_allowed_by_callback?() end |
#capture_allowed_by_callback?(message_or_exc) ⇒ Boolean
235 236 237 238 |
# File 'lib/raven/configuration.rb', line 235 def capture_allowed_by_callback?() return true unless should_capture should_capture.call(*[]) end |
#capture_in_current_environment? ⇒ Boolean
231 232 233 |
# File 'lib/raven/configuration.rb', line 231 def capture_in_current_environment? !!server && (environments.empty? || environments.include?(current_environment)) end |
#detect_release ⇒ Object
247 248 249 250 251 |
# File 'lib/raven/configuration.rb', line 247 def detect_release detect_release_from_heroku || detect_release_from_capistrano || detect_release_from_git end |
#verify! ⇒ Object
240 241 242 243 244 245 |
# File 'lib/raven/configuration.rb', line 240 def verify! raise Error.new('No server specified') unless server raise Error.new('No public key specified') unless public_key raise Error.new('No secret key specified') unless secret_key raise Error.new('No project ID specified') unless project_id end |