class Raven::Configuration

Constants

DEFAULT_PROCESSORS
IGNORE_DEFAULT

Attributes

app_dirs_pattern[RW]

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)/

async[R]

Optional Proc to be used to send events asynchronously.

async?[R]

Optional Proc to be used to send events asynchronously.

catch_debugged_exceptions[RW]

Deprecated accessor

context_lines[RW]

Number of lines of code context to capture, or nil for none

current_environment[R]
encoding[R]

Encoding type for event bodies

environments[RW]

Whitelist of environments that will send notifications to Sentry

excluded_exceptions[RW]

Which exceptions should never be sent

host[RW]
http_adapter[RW]

The Faraday adapter to be used. Will default to Net::HTTP when not set.

json_adapter[RW]

DEPRECATED: This option is now ignored as we use our own adapter.

logger[RW]

Logger to use internally

open_timeout[RW]

Timeout waiting for the connection to open in seconds

path[RW]
port[RW]
processors[RW]

Processors to run on data before sending upstream

project_id[RW]

Project ID number to send to the Sentry server

project_root[RW]

Project directory root

proxy[RW]

Proxy information to pass to the HTTP adapter

public_key[RW]

Public key for authentication with the Sentry server

rails_report_rescued_exceptions[RW]

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.

release[RW]
sanitize_credit_cards[RW]

Sanitize values that look like credit card numbers

sanitize_fields[RW]

additional fields to sanitize

scheme[RW]

Accessors for the component parts of the DSN

secret_key[RW]

Secret key for authentication with the Sentry server

send_modules[RW]

Include module versions in reports?

server[R]

Simple server string (setter provided below)

server_name[RW]
should_capture[RW]

Provide a configurable callback to determine event capture

silence_ready[RW]

Silence ready message

ssl[RW]

SSl settings passed direactly to faraday's ssl option

ssl_ca_file[RW]

The path to the SSL certificate file

ssl_verification[RW]

Should the SSL certificate of the server be verified?

tags[RW]

Default tags for events

timeout[RW]

Timeout when waiting for the server to return data in seconds

transport_failure_callback[RW]

Optional Proc, called when the Sentry server cannot be contacted for any reason

Public Class Methods

new() click to toggle source
# File lib/raven/configuration.rb, line 131
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 = 1
  self.open_timeout = 1
  self.proxy = nil
  self.tags = {}
  self.async = false
  self.rails_report_rescued_exceptions = true
  self.transport_failure_callback = false
  self.sanitize_fields = []
  self.sanitize_credit_cards = true
  self.environments = []

  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

Public Instance Methods

[](option) click to toggle source

Allows config options to be read like a hash

@param [Symbol] option Key for a given attribute

# File lib/raven/configuration.rb, line 202
def [](option)
  send(option)
end
async=(value) click to toggle source
# File lib/raven/configuration.rb, line 187
def async=(value)
  raise ArgumentError.new("async must be callable (or false to disable)") unless value == false || value.respond_to?(:call)
  @async = value
end
catch_debugged_exceptions=(boolean) click to toggle source
# File lib/raven/configuration.rb, line 236
def catch_debugged_exceptions=(boolean)
  Raven.logger.warn "DEPRECATION WARNING: catch_debugged_exceptions has been \
    renamed to rails_report_rescued_exceptions. catch_debugged_exceptions will \
    be removed in raven-ruby 0.17.0"
  self.rails_report_rescued_exceptions = boolean
end
current_environment=(environment) click to toggle source
# File lib/raven/configuration.rb, line 206
def current_environment=(environment)
  @current_environment = environment.to_s
end
detect_release() click to toggle source
# File lib/raven/configuration.rb, line 225
def detect_release
  detect_release_from_heroku ||
    detect_release_from_capistrano ||
    detect_release_from_git
end
dsn=(value)
Alias for: server=
encoding=(encoding) click to toggle source
# File lib/raven/configuration.rb, line 180
def encoding=(encoding)
  raise Error.new('Unsupported encoding') unless %w(gzip json).include? encoding
  @encoding = encoding
end
log_excluded_environment_message() click to toggle source
# File lib/raven/configuration.rb, line 214
def log_excluded_environment_message
  Raven.logger.debug "Event not sent due to excluded environment: #{current_environment}"
end
project_root=(root_dir) click to toggle source
# File lib/raven/configuration.rb, line 231
def project_root=(root_dir)
  @project_root = root_dir
  Backtrace::Line.instance_variable_set(:@in_app_pattern, nil) # blow away cache
end
send_in_current_environment?() click to toggle source
# File lib/raven/configuration.rb, line 210
def send_in_current_environment?
  !!server && (environments.empty? || environments.include?(current_environment))
end
server=(value) click to toggle source
# File lib/raven/configuration.rb, line 158
def server=(value)
  uri = URI.parse(value)
  uri_path = uri.path.split('/')

  if uri.user
    # DSN-style string
    @project_id = uri_path.pop
    @public_key = uri.user
    @secret_key = uri.password
  end

  @scheme = uri.scheme
  @host = uri.host
  @port = uri.port if uri.port
  @path = uri_path.join('/')

  # For anyone who wants to read the base server string
  @server = "#{@scheme}://#{@host}"
  @server << ":#{@port}" unless @port == { 'http' => 80, 'https' => 443 }[@scheme]
  @server << @path
end
Also aliased as: dsn=
transport_failure_callback=(value) click to toggle source
# File lib/raven/configuration.rb, line 194
def transport_failure_callback=(value)
  raise ArgumentError.new("transport_failure_callback must be callable (or false to disable)") unless value == false || value.respond_to?(:call)
  @transport_failure_callback = value
end
verify!() click to toggle source
# File lib/raven/configuration.rb, line 218
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