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.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/raven/configuration.rb', line 87

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::SanitizeData]
  self.ssl_verification = false
  self.encoding = 'json'
  self.timeout = 1
  self.open_timeout = 1
  self.tags = {}
  self.async = false
end

Instance Attribute Details

#app_dirs_patternObject

Exceptions from these directories to be ignored



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

def app_dirs_pattern
  @app_dirs_pattern
end

#asyncObject Also known as: async?

Optional Proc to be used to send events asynchronously.



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

def async
  @async
end

#context_linesObject

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



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

def context_lines
  @context_lines
end

#current_environmentObject

Returns the value of attribute current_environment.



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

def current_environment
  @current_environment
end

#encodingObject

Encoding type for event bodies



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

def encoding
  @encoding
end

#environmentsObject

Whitelist of environments that will send notifications to Sentry



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

def environments
  @environments
end

#excluded_exceptionsObject

Which exceptions should never be sent



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

def excluded_exceptions
  @excluded_exceptions
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#http_adapterObject

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



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

def http_adapter
  @http_adapter
end

#json_adapterObject

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



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

def json_adapter
  @json_adapter
end

#loggerObject

Logger to use internally



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

def logger
  @logger
end

#open_timeoutObject

Timeout waiting for the connection to open in seconds



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

def open_timeout
  @open_timeout
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#portObject

Returns the value of attribute port.



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

def port
  @port
end

#processorsObject

Processors to run on data before sending upstream



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

def processors
  @processors
end

#project_idObject

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_rootObject

Project directory root



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

def project_root
  @project_root
end

#public_keyObject

Public key for authentication with the Sentry server



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

def public_key
  @public_key
end

#schemeObject

Accessors for the component parts of the DSN



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

def scheme
  @scheme
end

#secret_keyObject

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_modulesObject

Include module versions in reports?



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

def send_modules
  @send_modules
end

#serverObject

Simple server string (setter provided below)



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

def server
  @server
end

#server_nameObject

Returns the value of attribute server_name.



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

def server_name
  @server_name
end

#sslObject

Ssl settings passed direactly to faraday’s ssl option



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

def ssl
  @ssl
end

#ssl_verificationObject

Should the SSL certificate of the server be verified?



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

def ssl_verification
  @ssl_verification
end

#tagsObject

Default tags for events



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

def tags
  @tags
end

#timeoutObject

Timeout when waiting for the server to return data in seconds



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

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



141
142
143
# File 'lib/raven/configuration.rb', line 141

def [](option)
  send(option)
end

#log_excluded_environment_messageObject



157
158
159
# File 'lib/raven/configuration.rb', line 157

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)


149
150
151
152
153
154
155
# File 'lib/raven/configuration.rb', line 149

def send_in_current_environment?
  if environments
    environments.include?(current_environment)
  else
    !%w[test cucumber development].include?(current_environment)
  end
end