Class: Raven::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/raven/configuration.rb

Constant Summary collapse

IGNORE_DEFAULT =
['ActiveRecord::RecordNotFound',
'ActionController::RoutingError',
'ActionController::InvalidAuthenticityToken',
'CGI::Session::CookieStore::TamperedWithCookie',
'ActionController::UnknownAction',
'AbstractController::ActionNotFound',
'Mongoid::Errors::DocumentNotFound']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/raven/configuration.rb', line 112

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
  self.processors = [Raven::Processor::RemoveCircularReferences, Raven::Processor::UTF8Conversion, Raven::Processor::SanitizeData]
  self.ssl_verification = true
  self.encoding = 'gzip'
  self.timeout = 1
  self.open_timeout = 1
  self.proxy = nil
  self.tags = {}
  self.async = false
  self.catch_debugged_exceptions = true
  self.sanitize_fields = []
  self.sanitize_credit_cards = true
  self.environments = []
end

Instance Attribute Details

#app_dirs_patternObject

Exceptions from these directories to be ignored



89
90
91
# File 'lib/raven/configuration.rb', line 89

def app_dirs_pattern
  @app_dirs_pattern
end

#asyncObject Also known as: async?

Optional Proc to be used to send events asynchronously.



86
87
88
# File 'lib/raven/configuration.rb', line 86

def async
  @async
end

#catch_debugged_exceptionsObject

Catch exceptions before they’re been processed by ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions



93
94
95
# File 'lib/raven/configuration.rb', line 93

def catch_debugged_exceptions
  @catch_debugged_exceptions
end

#context_linesObject

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



38
39
40
# File 'lib/raven/configuration.rb', line 38

def context_lines
  @context_lines
end

#current_environmentObject

Returns the value of attribute current_environment.



70
71
72
# File 'lib/raven/configuration.rb', line 70

def current_environment
  @current_environment
end

#encodingObject

Encoding type for event bodies



29
30
31
# File 'lib/raven/configuration.rb', line 29

def encoding
  @encoding
end

#environmentsObject

Whitelist of environments that will send notifications to Sentry



41
42
43
# File 'lib/raven/configuration.rb', line 41

def environments
  @environments
end

#excluded_exceptionsObject

Which exceptions should never be sent



47
48
49
# File 'lib/raven/configuration.rb', line 47

def excluded_exceptions
  @excluded_exceptions
end

#hostObject

Returns the value of attribute host.



18
19
20
# File 'lib/raven/configuration.rb', line 18

def host
  @host
end

#http_adapterObject

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



73
74
75
# File 'lib/raven/configuration.rb', line 73

def http_adapter
  @http_adapter
end

#json_adapterObject

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



80
81
82
# File 'lib/raven/configuration.rb', line 80

def json_adapter
  @json_adapter
end

#loggerObject

Logger to use internally



32
33
34
# File 'lib/raven/configuration.rb', line 32

def logger
  @logger
end

#open_timeoutObject

Timeout waiting for the connection to open in seconds



56
57
58
# File 'lib/raven/configuration.rb', line 56

def open_timeout
  @open_timeout
end

#pathObject

Returns the value of attribute path.



20
21
22
# File 'lib/raven/configuration.rb', line 20

def path
  @path
end

#portObject

Returns the value of attribute port.



19
20
21
# File 'lib/raven/configuration.rb', line 19

def port
  @port
end

#processorsObject

Processors to run on data before sending upstream



50
51
52
# File 'lib/raven/configuration.rb', line 50

def processors
  @processors
end

#project_idObject

Project ID number to send to the Sentry server



23
24
25
# File 'lib/raven/configuration.rb', line 23

def project_id
  @project_id
end

#project_rootObject

Project directory root



26
27
28
# File 'lib/raven/configuration.rb', line 26

def project_root
  @project_root
end

#proxyObject

Proxy information to pass to the HTTP adapter



68
69
70
# File 'lib/raven/configuration.rb', line 68

def proxy
  @proxy
end

#public_keyObject

Public key for authentication with the Sentry server



11
12
13
# File 'lib/raven/configuration.rb', line 11

def public_key
  @public_key
end

#releaseObject

Returns the value of attribute release.



77
78
79
# File 'lib/raven/configuration.rb', line 77

def release
  @release
end

#sanitize_credit_cardsObject

Sanitize values that look like credit card numbers



102
103
104
# File 'lib/raven/configuration.rb', line 102

def sanitize_credit_cards
  @sanitize_credit_cards
end

#sanitize_fieldsObject

additional fields to sanitize



99
100
101
# File 'lib/raven/configuration.rb', line 99

def sanitize_fields
  @sanitize_fields
end

#schemeObject

Accessors for the component parts of the DSN



17
18
19
# File 'lib/raven/configuration.rb', line 17

def scheme
  @scheme
end

#secret_keyObject

Secret key for authentication with the Sentry server



14
15
16
# File 'lib/raven/configuration.rb', line 14

def secret_key
  @secret_key
end

#send_modulesObject

Include module versions in reports?



44
45
46
# File 'lib/raven/configuration.rb', line 44

def send_modules
  @send_modules
end

#serverObject

Simple server string (setter provided below)



8
9
10
# File 'lib/raven/configuration.rb', line 8

def server
  @server
end

#server_nameObject

Returns the value of attribute server_name.



75
76
77
# File 'lib/raven/configuration.rb', line 75

def server_name
  @server_name
end

#should_captureObject

Provide a configurable callback to determine event capture



96
97
98
# File 'lib/raven/configuration.rb', line 96

def should_capture
  @should_capture
end

#silence_readyObject

Silence ready message



35
36
37
# File 'lib/raven/configuration.rb', line 35

def silence_ready
  @silence_ready
end

#sslObject

SSl settings passed direactly to faraday’s ssl option



65
66
67
# File 'lib/raven/configuration.rb', line 65

def ssl
  @ssl
end

#ssl_ca_fileObject

The path to the SSL certificate file



62
63
64
# File 'lib/raven/configuration.rb', line 62

def ssl_ca_file
  @ssl_ca_file
end

#ssl_verificationObject

Should the SSL certificate of the server be verified?



59
60
61
# File 'lib/raven/configuration.rb', line 59

def ssl_verification
  @ssl_verification
end

#tagsObject

Default tags for events



83
84
85
# File 'lib/raven/configuration.rb', line 83

def tags
  @tags
end

#timeoutObject

Timeout when waiting for the server to return data in seconds



53
54
55
# File 'lib/raven/configuration.rb', line 53

def timeout
  @timeout
end

Instance Method Details

#[](option) ⇒ Object

Allows config options to be read like a hash

Parameters:

  • option (Symbol)

    Key for a given attribute



171
172
173
# File 'lib/raven/configuration.rb', line 171

def [](option)
  send(option)
end

#log_excluded_environment_messageObject



183
184
185
# File 'lib/raven/configuration.rb', line 183

def log_excluded_environment_message
  Raven.logger.debug "Event not sent due to excluded environment: #{current_environment}"
end

#send_in_current_environment?Boolean

Returns:

  • (Boolean)


179
180
181
# File 'lib/raven/configuration.rb', line 179

def send_in_current_environment?
  !!server && (environments.empty? || environments.include?(current_environment))
end

#verify!Object

Raises:



187
188
189
190
191
192
# File 'lib/raven/configuration.rb', line 187

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