mustwin-sentry-raven 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/LICENSE +201 -0
- data/README.md +54 -0
- data/bin/raven +42 -0
- data/lib/raven.rb +3 -0
- data/lib/raven/backtrace.rb +128 -0
- data/lib/raven/base.rb +225 -0
- data/lib/raven/better_attr_accessor.rb +44 -0
- data/lib/raven/cli.rb +63 -0
- data/lib/raven/client.rb +104 -0
- data/lib/raven/configuration.rb +173 -0
- data/lib/raven/context.rb +21 -0
- data/lib/raven/error.rb +4 -0
- data/lib/raven/event.rb +223 -0
- data/lib/raven/integrations/delayed_job.rb +49 -0
- data/lib/raven/interfaces.rb +34 -0
- data/lib/raven/interfaces/exception.rb +22 -0
- data/lib/raven/interfaces/http.rb +53 -0
- data/lib/raven/interfaces/message.rb +17 -0
- data/lib/raven/interfaces/stack_trace.rb +55 -0
- data/lib/raven/linecache.rb +23 -0
- data/lib/raven/logger.rb +22 -0
- data/lib/raven/okjson.rb +609 -0
- data/lib/raven/processor.rb +28 -0
- data/lib/raven/processor/removecircularreferences.rb +17 -0
- data/lib/raven/processor/sanitizedata.rb +42 -0
- data/lib/raven/processor/utf8conversion.rb +26 -0
- data/lib/raven/rack.rb +75 -0
- data/lib/raven/rails/controller_methods.rb +13 -0
- data/lib/raven/rails/middleware/debug_exceptions_catcher.rb +16 -0
- data/lib/raven/railtie.rb +38 -0
- data/lib/raven/rake.rb +13 -0
- data/lib/raven/sidekiq.rb +27 -0
- data/lib/raven/tasks.rb +12 -0
- data/lib/raven/transports.rb +27 -0
- data/lib/raven/transports/http.rb +56 -0
- data/lib/raven/transports/udp.rb +30 -0
- data/lib/raven/version.rb +3 -0
- data/lib/sentry-raven.rb +1 -0
- metadata +168 -0
data/lib/raven/base.rb
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
require 'raven/version'
|
2
|
+
require 'raven/backtrace'
|
3
|
+
require 'raven/configuration'
|
4
|
+
require 'raven/context'
|
5
|
+
require 'raven/client'
|
6
|
+
require 'raven/event'
|
7
|
+
require 'raven/logger'
|
8
|
+
require 'raven/rack'
|
9
|
+
require 'raven/interfaces/message'
|
10
|
+
require 'raven/interfaces/exception'
|
11
|
+
require 'raven/interfaces/stack_trace'
|
12
|
+
require 'raven/interfaces/http'
|
13
|
+
require 'raven/processor'
|
14
|
+
require 'raven/processor/sanitizedata'
|
15
|
+
require 'raven/processor/removecircularreferences'
|
16
|
+
require 'raven/processor/utf8conversion'
|
17
|
+
|
18
|
+
module Raven
|
19
|
+
class << self
|
20
|
+
# The client object is responsible for delivering formatted data to the Sentry server.
|
21
|
+
# Must respond to #send. See Raven::Client.
|
22
|
+
attr_writer :client
|
23
|
+
|
24
|
+
# A Raven configuration object. Must act like a hash and return sensible
|
25
|
+
# values for all Raven configuration options. See Raven::Configuration.
|
26
|
+
attr_writer :configuration
|
27
|
+
|
28
|
+
def context
|
29
|
+
Context.current
|
30
|
+
end
|
31
|
+
|
32
|
+
def logger
|
33
|
+
@logger ||= Logger.new
|
34
|
+
end
|
35
|
+
|
36
|
+
# The configuration object.
|
37
|
+
# @see Raven.configure
|
38
|
+
def configuration
|
39
|
+
@configuration ||= Configuration.new
|
40
|
+
end
|
41
|
+
|
42
|
+
# The client object is responsible for delivering formatted data to the Sentry server.
|
43
|
+
def client
|
44
|
+
@client ||= Client.new(configuration)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Tell the log that the client is good to go
|
48
|
+
def report_ready
|
49
|
+
self.logger.info "Raven #{VERSION} ready to catch errors"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Call this method to modify defaults in your initializers.
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# Raven.configure do |config|
|
56
|
+
# config.server = 'http://...'
|
57
|
+
# end
|
58
|
+
def configure(silent = false)
|
59
|
+
yield(configuration) if block_given?
|
60
|
+
|
61
|
+
self.client = Client.new(configuration)
|
62
|
+
report_ready unless silent
|
63
|
+
self.client
|
64
|
+
end
|
65
|
+
|
66
|
+
# Send an event to the configured Sentry server
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# evt = Raven::Event.new(:message => "An error")
|
70
|
+
# Raven.send(evt)
|
71
|
+
def send(evt)
|
72
|
+
client.send(evt)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Capture and process any exceptions from the given block, or globally if
|
76
|
+
# no block is given
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# Raven.capture do
|
80
|
+
# MyApp.run
|
81
|
+
# end
|
82
|
+
def capture(options = {}, &block)
|
83
|
+
if block
|
84
|
+
begin
|
85
|
+
block.call
|
86
|
+
rescue Error
|
87
|
+
raise # Don't capture Raven errors
|
88
|
+
rescue Exception => e
|
89
|
+
capture_exception(e, options)
|
90
|
+
raise
|
91
|
+
end
|
92
|
+
else
|
93
|
+
# Install at_exit hook
|
94
|
+
at_exit do
|
95
|
+
if $ERROR_INFO
|
96
|
+
logger.debug "Caught a post-mortem exception: #{$ERROR_INFO.inspect}"
|
97
|
+
capture_exception($ERROR_INFO, options)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def capture_exception(exception, options = {})
|
104
|
+
send_or_skip(exception) do
|
105
|
+
if evt = Event.from_exception(exception, options)
|
106
|
+
yield evt if block_given?
|
107
|
+
if configuration.async?
|
108
|
+
configuration.async.call(evt)
|
109
|
+
else
|
110
|
+
send(evt)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def capture_message(message, options = {})
|
117
|
+
send_or_skip(message) do
|
118
|
+
if evt = Event.from_message(message, options)
|
119
|
+
yield evt if block_given?
|
120
|
+
if configuration.async?
|
121
|
+
configuration.async.call(evt)
|
122
|
+
else
|
123
|
+
send(evt)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def send_or_skip(exc)
|
130
|
+
should_send = if configuration.should_send
|
131
|
+
configuration.should_send.call(*[exc])
|
132
|
+
else
|
133
|
+
true
|
134
|
+
end
|
135
|
+
|
136
|
+
if configuration.send_in_current_environment? && should_send
|
137
|
+
yield if block_given?
|
138
|
+
else
|
139
|
+
configuration.log_excluded_environment_message
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Provides extra context to the exception prior to it being handled by
|
144
|
+
# Raven. An exception can have multiple annotations, which are merged
|
145
|
+
# together.
|
146
|
+
#
|
147
|
+
# The options (annotation) is treated the same as the ``options``
|
148
|
+
# parameter to ``capture_exception`` or ``Event.from_exception``, and
|
149
|
+
# can contain the same ``:user``, ``:tags``, etc. options as these
|
150
|
+
# methods.
|
151
|
+
#
|
152
|
+
# These will be merged with the ``options`` parameter to
|
153
|
+
# ``Event.from_exception`` at the top of execution.
|
154
|
+
#
|
155
|
+
# @example
|
156
|
+
# begin
|
157
|
+
# raise "Hello"
|
158
|
+
# rescue => exc
|
159
|
+
# Raven.annotate_exception(exc, :user => { 'id' => 1,
|
160
|
+
# 'email' => 'foo@example.com' })
|
161
|
+
# end
|
162
|
+
def annotate_exception(exc, options = {})
|
163
|
+
notes = exc.instance_variable_get(:@__raven_context) || {}
|
164
|
+
notes.merge!(options)
|
165
|
+
exc.instance_variable_set(:@__raven_context, notes)
|
166
|
+
exc
|
167
|
+
end
|
168
|
+
|
169
|
+
# Bind user context. Merges with existing context (if any).
|
170
|
+
#
|
171
|
+
# It is recommending that you send at least the ``id`` and ``email``
|
172
|
+
# values. All other values are arbitrary.
|
173
|
+
#
|
174
|
+
# @example
|
175
|
+
# Raven.user_context('id' => 1, 'email' => 'foo@example.com')
|
176
|
+
def user_context(options = {})
|
177
|
+
self.context.user = options
|
178
|
+
end
|
179
|
+
|
180
|
+
# Bind tags context. Merges with existing context (if any).
|
181
|
+
#
|
182
|
+
# Tags are key / value pairs which generally represent things like application version,
|
183
|
+
# environment, role, and server names.
|
184
|
+
#
|
185
|
+
# @example
|
186
|
+
# Raven.tags_context('my_custom_tag' => 'tag_value')
|
187
|
+
def tags_context(options = {})
|
188
|
+
self.context.tags.merge!(options)
|
189
|
+
end
|
190
|
+
|
191
|
+
# Bind extra context. Merges with existing context (if any).
|
192
|
+
#
|
193
|
+
# Extra context shows up as Additional Data within Sentry, and is completely arbitrary.
|
194
|
+
#
|
195
|
+
# @example
|
196
|
+
# Raven.tags_context('my_custom_data' => 'value')
|
197
|
+
def extra_context(options = {})
|
198
|
+
self.context.extra.merge!(options)
|
199
|
+
end
|
200
|
+
|
201
|
+
def rack_context(env)
|
202
|
+
if env.empty?
|
203
|
+
env = nil
|
204
|
+
end
|
205
|
+
self.context.rack_env = env
|
206
|
+
end
|
207
|
+
|
208
|
+
# Injects various integrations
|
209
|
+
def inject
|
210
|
+
require 'raven/integrations/delayed_job' if defined?(::Delayed::Plugin)
|
211
|
+
require 'raven/railtie' if defined?(::Rails::Railtie)
|
212
|
+
require 'raven/sidekiq' if defined?(Sidekiq)
|
213
|
+
if defined?(Rake)
|
214
|
+
require 'raven/rake'
|
215
|
+
require 'raven/tasks'
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# For cross-language compat
|
220
|
+
alias :captureException :capture_exception
|
221
|
+
alias :captureMessage :capture_message
|
222
|
+
alias :annotateException :annotate_exception
|
223
|
+
alias :annotate :annotate_exception
|
224
|
+
end
|
225
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Raven
|
4
|
+
module BetterAttrAccessor
|
5
|
+
|
6
|
+
def attributes
|
7
|
+
Hash[
|
8
|
+
self.class.attributes.map do |attr|
|
9
|
+
[attr, send(attr)]
|
10
|
+
end
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.included(base)
|
15
|
+
base.extend ClassMethods
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
def attributes
|
20
|
+
@attributes ||= Set.new
|
21
|
+
|
22
|
+
if superclass.include? BetterAttrAccessor
|
23
|
+
@attributes + superclass.attributes
|
24
|
+
else
|
25
|
+
@attributes
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def attr_accessor(attr, options = {})
|
30
|
+
@attributes ||= Set.new
|
31
|
+
@attributes << attr.to_s
|
32
|
+
|
33
|
+
define_method attr do
|
34
|
+
if instance_variable_defined? "@#{attr}"
|
35
|
+
instance_variable_get "@#{attr}"
|
36
|
+
elsif options.key? :default
|
37
|
+
instance_variable_set "@#{attr}", options[:default].dup
|
38
|
+
end
|
39
|
+
end
|
40
|
+
attr_writer attr
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/raven/cli.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'raven'
|
2
|
+
|
3
|
+
module Raven
|
4
|
+
class CLI
|
5
|
+
def self.test(dsn = nil)
|
6
|
+
require 'logger'
|
7
|
+
|
8
|
+
logger = ::Logger.new(STDOUT)
|
9
|
+
logger.level = ::Logger::ERROR
|
10
|
+
logger.formatter = proc do |severity, datetime, progname, msg|
|
11
|
+
"-> #{msg}\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
Raven.configuration.logger = logger
|
15
|
+
Raven.configuration.timeout = 5
|
16
|
+
Raven.configuration.dsn = dsn if dsn
|
17
|
+
|
18
|
+
# wipe out env settings to ensure we send the event
|
19
|
+
unless Raven.configuration.send_in_current_environment?
|
20
|
+
environments = Raven.configuration.environments
|
21
|
+
env_name = (environments && environments[0]) || 'production'
|
22
|
+
puts "Setting environment to #{env_name}"
|
23
|
+
Raven.configuration.current_environment = env_name
|
24
|
+
end
|
25
|
+
|
26
|
+
unless Raven.configuration.server
|
27
|
+
puts "Your client is not configured!"
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "Client configuration:"
|
32
|
+
['server', 'project_id', 'public_key', 'secret_key'].each do |key|
|
33
|
+
unless Raven.configuration[key]
|
34
|
+
puts "Missing configuration for #{key}"
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
puts "-> #{key}: #{Raven.configuration[key]}"
|
38
|
+
end
|
39
|
+
puts ""
|
40
|
+
|
41
|
+
puts "Sending a test event:"
|
42
|
+
|
43
|
+
begin
|
44
|
+
1 / 0
|
45
|
+
rescue ZeroDivisionError => exception
|
46
|
+
evt = Raven.capture_exception(exception)
|
47
|
+
end
|
48
|
+
|
49
|
+
if evt && !(evt.is_a? Thread)
|
50
|
+
puts "-> event ID: #{evt.id}"
|
51
|
+
elsif evt #async configuration
|
52
|
+
puts "-> event ID: #{evt.value.id}"
|
53
|
+
else
|
54
|
+
puts ""
|
55
|
+
puts "An error occurred while attempting to send the event."
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
|
59
|
+
puts ""
|
60
|
+
puts "Done!"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/raven/client.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
require 'raven/version'
|
5
|
+
require 'raven/okjson'
|
6
|
+
require 'raven/transports/http'
|
7
|
+
require 'raven/transports/udp'
|
8
|
+
|
9
|
+
module Raven
|
10
|
+
|
11
|
+
class Client
|
12
|
+
|
13
|
+
PROTOCOL_VERSION = '5'
|
14
|
+
USER_AGENT = "raven-ruby/#{Raven::VERSION}"
|
15
|
+
CONTENT_TYPE = 'application/json'
|
16
|
+
|
17
|
+
attr_accessor :configuration
|
18
|
+
|
19
|
+
def initialize(configuration)
|
20
|
+
@configuration = configuration
|
21
|
+
@processors = configuration.processors.map { |v| v.new(self) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def send(event)
|
25
|
+
unless configuration.send_in_current_environment?
|
26
|
+
configuration.log_excluded_environment_message
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
# Set the project ID correctly
|
31
|
+
event.project = self.configuration.project_id
|
32
|
+
Raven.logger.debug "Sending event #{event.id} to Sentry"
|
33
|
+
|
34
|
+
content_type, encoded_data = encode(event)
|
35
|
+
begin
|
36
|
+
transport.send(generate_auth_header(encoded_data), encoded_data,
|
37
|
+
:content_type => content_type)
|
38
|
+
rescue => e
|
39
|
+
Raven.logger.error "Unable to record event with remote Sentry server (#{e.class} - #{e.message})"
|
40
|
+
e.backtrace[0..10].each { |line| Raven.logger.error(line) }
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
event
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def encode(event)
|
50
|
+
hash = event.to_hash
|
51
|
+
|
52
|
+
# apply processors
|
53
|
+
hash = @processors.reduce(hash) do |memo, processor|
|
54
|
+
processor.process(memo)
|
55
|
+
end
|
56
|
+
|
57
|
+
encoded = OkJson.encode(hash)
|
58
|
+
|
59
|
+
case self.configuration.encoding
|
60
|
+
when 'gzip'
|
61
|
+
gzipped = Zlib::Deflate.deflate(encoded)
|
62
|
+
b64_encoded = strict_encode64(gzipped)
|
63
|
+
return 'application/octet-stream', b64_encoded
|
64
|
+
else
|
65
|
+
return 'application/json', encoded
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def transport
|
70
|
+
@transport ||=
|
71
|
+
case self.configuration.scheme
|
72
|
+
when 'udp'
|
73
|
+
Transports::UDP.new self.configuration
|
74
|
+
when 'http', 'https'
|
75
|
+
Transports::HTTP.new self.configuration
|
76
|
+
else
|
77
|
+
raise Error.new("Unknown transport scheme '#{self.configuration.scheme}'")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def generate_auth_header(data)
|
82
|
+
now = Time.now.to_i.to_s
|
83
|
+
fields = {
|
84
|
+
'sentry_version' => PROTOCOL_VERSION,
|
85
|
+
'sentry_client' => USER_AGENT,
|
86
|
+
'sentry_timestamp' => now,
|
87
|
+
'sentry_key' => self.configuration.public_key,
|
88
|
+
'sentry_secret' => self.configuration.secret_key,
|
89
|
+
}
|
90
|
+
'Sentry ' + fields.map { |key, value| "#{key}=#{value}" }.join(', ')
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def strict_encode64(string)
|
96
|
+
if Base64.respond_to? :strict_encode64
|
97
|
+
Base64.strict_encode64 string
|
98
|
+
else # Ruby 1.8
|
99
|
+
Base64.encode64(string)[0..-2]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Raven
|
4
|
+
class Configuration
|
5
|
+
|
6
|
+
# Simple server string (setter provided below)
|
7
|
+
attr_reader :server
|
8
|
+
|
9
|
+
# Public key for authentication with the Sentry server
|
10
|
+
attr_accessor :public_key
|
11
|
+
|
12
|
+
# Secret key for authentication with the Sentry server
|
13
|
+
attr_accessor :secret_key
|
14
|
+
|
15
|
+
# Accessors for the component parts of the DSN
|
16
|
+
attr_accessor :scheme
|
17
|
+
attr_accessor :host
|
18
|
+
attr_accessor :port
|
19
|
+
attr_accessor :path
|
20
|
+
|
21
|
+
# Project ID number to send to the Sentry server
|
22
|
+
attr_accessor :project_id
|
23
|
+
|
24
|
+
# Project directory root
|
25
|
+
attr_accessor :project_root
|
26
|
+
|
27
|
+
# Encoding type for event bodies
|
28
|
+
attr_reader :encoding
|
29
|
+
|
30
|
+
# Logger to use internally
|
31
|
+
attr_accessor :logger
|
32
|
+
|
33
|
+
# Number of lines of code context to capture, or nil for none
|
34
|
+
attr_accessor :context_lines
|
35
|
+
|
36
|
+
# Whitelist of environments that will send notifications to Sentry
|
37
|
+
attr_accessor :environments
|
38
|
+
|
39
|
+
# Include module versions in reports?
|
40
|
+
attr_accessor :send_modules
|
41
|
+
|
42
|
+
# Which exceptions should never be sent
|
43
|
+
attr_accessor :excluded_exceptions
|
44
|
+
|
45
|
+
# Processors to run on data before sending upstream
|
46
|
+
attr_accessor :processors
|
47
|
+
|
48
|
+
# Timeout when waiting for the server to return data in seconds
|
49
|
+
attr_accessor :timeout
|
50
|
+
|
51
|
+
# Timeout waiting for the connection to open in seconds
|
52
|
+
attr_accessor :open_timeout
|
53
|
+
|
54
|
+
# Should the SSL certificate of the server be verified?
|
55
|
+
attr_accessor :ssl_verification
|
56
|
+
|
57
|
+
# Ssl settings passed direactly to faraday's ssl option
|
58
|
+
attr_accessor :ssl
|
59
|
+
|
60
|
+
attr_reader :current_environment
|
61
|
+
|
62
|
+
# The Faraday adapter to be used. Will default to Net::HTTP when not set.
|
63
|
+
attr_accessor :http_adapter
|
64
|
+
|
65
|
+
attr_accessor :server_name
|
66
|
+
|
67
|
+
# DEPRECATED: This option is now ignored as we use our own adapter.
|
68
|
+
attr_accessor :json_adapter
|
69
|
+
|
70
|
+
# Default tags for events
|
71
|
+
attr_accessor :tags
|
72
|
+
|
73
|
+
# Optional Proc to be used to send events asynchronously.
|
74
|
+
attr_reader :async
|
75
|
+
|
76
|
+
# Exceptions from these directories to be ignored
|
77
|
+
attr_accessor :app_dirs_pattern
|
78
|
+
|
79
|
+
# Catch exceptions before they're been processed by
|
80
|
+
# ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions
|
81
|
+
attr_accessor :catch_debugged_exceptions
|
82
|
+
|
83
|
+
# Provide a configurable callback to block or send events
|
84
|
+
attr_accessor :should_send
|
85
|
+
|
86
|
+
# additional fields to sanitize
|
87
|
+
attr_accessor :sanitize_fields
|
88
|
+
|
89
|
+
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
90
|
+
'ActionController::RoutingError',
|
91
|
+
'ActionController::InvalidAuthenticityToken',
|
92
|
+
'CGI::Session::CookieStore::TamperedWithCookie',
|
93
|
+
'ActionController::UnknownAction',
|
94
|
+
'AbstractController::ActionNotFound',
|
95
|
+
'Mongoid::Errors::DocumentNotFound']
|
96
|
+
|
97
|
+
def initialize
|
98
|
+
self.server = ENV['SENTRY_DSN'] if ENV['SENTRY_DSN']
|
99
|
+
@context_lines = 3
|
100
|
+
self.current_environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default'
|
101
|
+
self.send_modules = true
|
102
|
+
self.excluded_exceptions = IGNORE_DEFAULT
|
103
|
+
self.processors = [Raven::Processor::RemoveCircularReferences, Raven::Processor::UTF8Conversion, Raven::Processor::SanitizeData]
|
104
|
+
self.ssl_verification = false
|
105
|
+
self.encoding = 'gzip'
|
106
|
+
self.timeout = 1
|
107
|
+
self.open_timeout = 1
|
108
|
+
self.tags = {}
|
109
|
+
self.async = false
|
110
|
+
self.catch_debugged_exceptions = true
|
111
|
+
self.sanitize_fields = []
|
112
|
+
end
|
113
|
+
|
114
|
+
def server=(value)
|
115
|
+
uri = URI.parse(value)
|
116
|
+
uri_path = uri.path.split('/')
|
117
|
+
|
118
|
+
if uri.user
|
119
|
+
# DSN-style string
|
120
|
+
@project_id = uri_path.pop
|
121
|
+
@public_key = uri.user
|
122
|
+
@secret_key = uri.password
|
123
|
+
end
|
124
|
+
|
125
|
+
@scheme = uri.scheme
|
126
|
+
@host = uri.host
|
127
|
+
@port = uri.port if uri.port
|
128
|
+
@path = uri_path.join('/')
|
129
|
+
|
130
|
+
# For anyone who wants to read the base server string
|
131
|
+
@server = "#{@scheme}://#{@host}"
|
132
|
+
@server << ":#{@port}" unless @port == { 'http' => 80, 'https' => 443 }[@scheme]
|
133
|
+
@server << @path
|
134
|
+
end
|
135
|
+
|
136
|
+
def encoding=(encoding)
|
137
|
+
raise Error.new('Unsupported encoding') unless ['gzip', 'json'].include? encoding
|
138
|
+
@encoding = encoding
|
139
|
+
end
|
140
|
+
|
141
|
+
alias_method :dsn=, :server=
|
142
|
+
|
143
|
+
def async=(value)
|
144
|
+
raise ArgumentError.new("async must be callable (or false to disable)") unless (value == false || value.respond_to?(:call))
|
145
|
+
@async = value
|
146
|
+
end
|
147
|
+
|
148
|
+
alias_method :async?, :async
|
149
|
+
|
150
|
+
# Allows config options to be read like a hash
|
151
|
+
#
|
152
|
+
# @param [Symbol] option Key for a given attribute
|
153
|
+
def [](option)
|
154
|
+
send(option)
|
155
|
+
end
|
156
|
+
|
157
|
+
def current_environment=(environment)
|
158
|
+
@current_environment = environment.to_s
|
159
|
+
end
|
160
|
+
|
161
|
+
def send_in_current_environment?
|
162
|
+
if environments
|
163
|
+
environments.include?(current_environment)
|
164
|
+
else
|
165
|
+
true
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def log_excluded_environment_message
|
170
|
+
Raven.logger.debug "Event not sent due to excluded environment: #{current_environment}"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|