sentry-raven 0.14.0 → 0.15.0
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 +4 -4
- data/README.md +2 -2
- data/lib/raven/base.rb +35 -17
- data/lib/raven/configuration.rb +0 -2
- data/lib/raven/event.rb +11 -3
- data/lib/raven/integrations/rack.rb +4 -4
- data/lib/raven/integrations/rails/active_job.rb +8 -1
- data/lib/raven/processor/sanitizedata.rb +13 -2
- data/lib/raven/version.rb +1 -1
- data/lib/sentry-raven-without-integrations.rb +1 -0
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dccadb5ecbfd08ce2f10b61d81cfde82d980751e
|
4
|
+
data.tar.gz: fa8760022edb8215192bc6d2a2317443dd0d5822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a45c18169fbf7550dbad9e107b21299640731b4b97243aa7198659bfaa5f9a13cff02b28228c8db0ac03da47c93ba75e8c8adf939a457ba226c38190456e897
|
7
|
+
data.tar.gz: ab542dc0fbc59a729c3f4b95c0e206a1fc067378d4a99c92cf77603d40872f9aad0acb3c03b3b8c07f8485f36e2617f71422e2b89732ba584d08d9748b045916
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ end
|
|
47
47
|
Full documentation and more information on advanced configuration, sending more information, scrubbing sensitive data, and more can be found on [the wiki](https://github.com/getsentry/raven-ruby/wiki).
|
48
48
|
|
49
49
|
* [Documentation](https://github.com/getsentry/raven-ruby/wiki)
|
50
|
-
* [Bug Tracker](
|
51
|
-
* [Code](
|
50
|
+
* [Bug Tracker](https://github.com/getsentry/raven-ruby/issues>)
|
51
|
+
* [Code](https://github.com/getsentry/raven-ruby>)
|
52
52
|
* [Mailing List](https://groups.google.com/group/getsentry>)
|
53
53
|
* [IRC](irc://irc.freenode.net/sentry>) (irc.freenode.net, #sentry)
|
data/lib/raven/base.rb
CHANGED
@@ -21,6 +21,8 @@ if (major == 1 && minor < 9) || (major == 1 && minor == 9 && patch < 2)
|
|
21
21
|
end
|
22
22
|
|
23
23
|
module Raven
|
24
|
+
AVAILABLE_INTEGRATIONS = %w[delayed_job railties sidekiq rack rake]
|
25
|
+
|
24
26
|
class << self
|
25
27
|
# The client object is responsible for delivering formatted data to the Sentry server.
|
26
28
|
# Must respond to #send. See Raven::Client.
|
@@ -169,8 +171,8 @@ module Raven
|
|
169
171
|
#
|
170
172
|
# @example
|
171
173
|
# Raven.user_context('id' => 1, 'email' => 'foo@example.com')
|
172
|
-
def user_context(options =
|
173
|
-
self.context.user = options
|
174
|
+
def user_context(options = nil)
|
175
|
+
self.context.user = options || {}
|
174
176
|
end
|
175
177
|
|
176
178
|
# Bind tags context. Merges with existing context (if any).
|
@@ -180,8 +182,8 @@ module Raven
|
|
180
182
|
#
|
181
183
|
# @example
|
182
184
|
# Raven.tags_context('my_custom_tag' => 'tag_value')
|
183
|
-
def tags_context(options =
|
184
|
-
self.context.tags.merge!(options)
|
185
|
+
def tags_context(options = nil)
|
186
|
+
self.context.tags.merge!(options || {})
|
185
187
|
end
|
186
188
|
|
187
189
|
# Bind extra context. Merges with existing context (if any).
|
@@ -190,8 +192,8 @@ module Raven
|
|
190
192
|
#
|
191
193
|
# @example
|
192
194
|
# Raven.extra_context('my_custom_data' => 'value')
|
193
|
-
def extra_context(options =
|
194
|
-
self.context.extra.merge!(options)
|
195
|
+
def extra_context(options = nil)
|
196
|
+
self.context.extra.merge!(options || {})
|
195
197
|
end
|
196
198
|
|
197
199
|
def rack_context(env)
|
@@ -201,23 +203,39 @@ module Raven
|
|
201
203
|
self.context.rack_env = env
|
202
204
|
end
|
203
205
|
|
204
|
-
# Injects various integrations
|
206
|
+
# Injects various integrations. Default behavior: inject all available integrations
|
205
207
|
def inject
|
206
|
-
|
207
|
-
|
208
|
+
inject_only(*Raven::AVAILABLE_INTEGRATIONS)
|
209
|
+
end
|
210
|
+
|
211
|
+
def inject_without(*exclude_integrations)
|
212
|
+
include_integrations = Raven::AVAILABLE_INTEGRATIONS - exclude_integrations.map(&:to_s)
|
213
|
+
inject_only(*include_integrations)
|
214
|
+
end
|
215
|
+
|
216
|
+
def inject_only(*only_integrations)
|
217
|
+
only_integrations = only_integrations.map(&:to_s)
|
218
|
+
integrations_to_load = Raven::AVAILABLE_INTEGRATIONS & only_integrations
|
219
|
+
not_found_integrations = only_integrations - integrations_to_load
|
220
|
+
if not_found_integrations.any?
|
221
|
+
self.logger.warn "Integrations do not exist: #{not_found_integrations.join ', '}"
|
222
|
+
end
|
223
|
+
integrations_to_load &= Gem.loaded_specs.keys
|
208
224
|
# TODO(dcramer): integrations should have some additional checks baked-in
|
209
225
|
# or we should break them out into their own repos. Specifically both the
|
210
226
|
# rails and delayed_job checks are not always valid (i.e. Rails 2.3) and
|
211
227
|
# https://github.com/getsentry/raven-ruby/issues/180
|
212
228
|
integrations_to_load.each do |integration|
|
213
|
-
|
214
|
-
require "raven/integrations/#{integration}"
|
215
|
-
rescue Exception => error
|
216
|
-
self.logger.warn "Unable to load raven/integrations/#{integration}: #{error}"
|
217
|
-
end
|
229
|
+
load_integration(integration)
|
218
230
|
end
|
219
231
|
end
|
220
232
|
|
233
|
+
def load_integration(integration)
|
234
|
+
require "raven/integrations/#{integration}"
|
235
|
+
rescue Exception => error
|
236
|
+
self.logger.warn "Unable to load raven/integrations/#{integration}: #{error}"
|
237
|
+
end
|
238
|
+
|
221
239
|
# For cross-language compat
|
222
240
|
alias :captureException :capture_exception
|
223
241
|
alias :captureMessage :capture_message
|
@@ -228,9 +246,9 @@ module Raven
|
|
228
246
|
|
229
247
|
def install_at_exit_hook(options)
|
230
248
|
at_exit do
|
231
|
-
if
|
232
|
-
logger.debug "Caught a post-mortem exception: #{
|
233
|
-
capture_exception(
|
249
|
+
if $!
|
250
|
+
logger.debug "Caught a post-mortem exception: #{$!.inspect}"
|
251
|
+
capture_exception($!, options)
|
234
252
|
end
|
235
253
|
end
|
236
254
|
end
|
data/lib/raven/configuration.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'certifi'
|
2
1
|
require 'logger'
|
3
2
|
require 'uri'
|
4
3
|
|
@@ -118,7 +117,6 @@ module Raven
|
|
118
117
|
self.excluded_exceptions = IGNORE_DEFAULT
|
119
118
|
self.processors = [Raven::Processor::RemoveCircularReferences, Raven::Processor::UTF8Conversion, Raven::Processor::SanitizeData]
|
120
119
|
self.ssl_verification = true
|
121
|
-
self.ssl_ca_file = Certifi.where
|
122
120
|
self.encoding = 'gzip'
|
123
121
|
self.timeout = 1
|
124
122
|
self.open_timeout = 1
|
data/lib/raven/event.rb
CHANGED
@@ -26,7 +26,7 @@ module Raven
|
|
26
26
|
attr_reader :id
|
27
27
|
attr_accessor :project, :message, :timestamp, :time_spent, :level, :logger,
|
28
28
|
:culprit, :server_name, :release, :modules, :extra, :tags, :context, :configuration,
|
29
|
-
:checksum
|
29
|
+
:checksum, :fingerprint
|
30
30
|
|
31
31
|
def initialize(init = {})
|
32
32
|
@configuration = Raven.configuration
|
@@ -37,7 +37,7 @@ module Raven
|
|
37
37
|
@timestamp = Time.now.utc
|
38
38
|
@time_spent = nil
|
39
39
|
@level = :error
|
40
|
-
@logger = '
|
40
|
+
@logger = ''
|
41
41
|
@culprit = nil
|
42
42
|
@server_name = @configuration.server_name || get_hostname
|
43
43
|
@release = @configuration.release
|
@@ -46,6 +46,7 @@ module Raven
|
|
46
46
|
@extra = {}
|
47
47
|
@tags = {}
|
48
48
|
@checksum = nil
|
49
|
+
@fingerprint = nil
|
49
50
|
|
50
51
|
yield self if block_given?
|
51
52
|
|
@@ -101,12 +102,13 @@ module Raven
|
|
101
102
|
:time_spent => @time_spent,
|
102
103
|
:level => @level,
|
103
104
|
:project => @project,
|
104
|
-
:logger => @logger,
|
105
105
|
:platform => PLATFORM,
|
106
106
|
}
|
107
|
+
data[:logger] = @logger if @logger
|
107
108
|
data[:culprit] = @culprit if @culprit
|
108
109
|
data[:server_name] = @server_name if @server_name
|
109
110
|
data[:release] = @release if @release
|
111
|
+
data[:fingerprint] = @fingerprint if @fingerprint
|
110
112
|
data[:modules] = @modules if @modules
|
111
113
|
data[:extra] = @extra if @extra
|
112
114
|
data[:tags] = @tags if @tags
|
@@ -164,9 +166,15 @@ module Raven
|
|
164
166
|
def self.add_exception_interface(evt, exc)
|
165
167
|
evt.interface(:exception) do |exc_int|
|
166
168
|
exceptions = [exc]
|
169
|
+
context = Set.new [exc.object_id]
|
167
170
|
while exc.respond_to?(:cause) && exc.cause
|
168
171
|
exceptions << exc.cause
|
169
172
|
exc = exc.cause
|
173
|
+
# TODO(dcramer): ideally this would log to inform the user
|
174
|
+
if context.include?(exc.object_id)
|
175
|
+
break
|
176
|
+
end
|
177
|
+
context.add(exc.object_id)
|
170
178
|
end
|
171
179
|
exceptions.reverse!
|
172
180
|
|
@@ -23,8 +23,8 @@ module Raven
|
|
23
23
|
class Rack
|
24
24
|
|
25
25
|
def self.capture_type(exception, env, options = {})
|
26
|
-
if env['requested_at']
|
27
|
-
options[:time_spent] = Time.now - env['requested_at']
|
26
|
+
if env['raven.requested_at']
|
27
|
+
options[:time_spent] = Time.now - env['raven.requested_at']
|
28
28
|
end
|
29
29
|
Raven.capture_type(exception, options) do |evt|
|
30
30
|
evt.interface :http do |int|
|
@@ -47,7 +47,7 @@ module Raven
|
|
47
47
|
|
48
48
|
# store the current environment in our local context for arbitrary
|
49
49
|
# callers
|
50
|
-
env['requested_at'] = Time.now
|
50
|
+
env['raven.requested_at'] = Time.now
|
51
51
|
Raven.rack_context(env)
|
52
52
|
|
53
53
|
begin
|
@@ -60,7 +60,7 @@ module Raven
|
|
60
60
|
raise
|
61
61
|
end
|
62
62
|
|
63
|
-
error = env['rack.exception'] || env['sinatra.error']
|
63
|
+
error = env['rack.exception'] || env['sinatra.error'] || env['action_dispatch.exception']
|
64
64
|
|
65
65
|
Raven::Rack.capture_exception(error, env) if error
|
66
66
|
|
@@ -7,7 +7,14 @@ module Raven
|
|
7
7
|
# Do not capture exceptions when using Sidekiq so we don't capture
|
8
8
|
# The same exception twice.
|
9
9
|
unless self.class.queue_adapter.to_s == 'ActiveJob::QueueAdapters::SidekiqAdapter'
|
10
|
-
Raven.capture_exception(exception, :extra => {
|
10
|
+
Raven.capture_exception(exception, :extra => {
|
11
|
+
:active_job => self.class.name,
|
12
|
+
:arguments => arguments,
|
13
|
+
:scheduled_at => scheduled_at,
|
14
|
+
:job_id => job_id,
|
15
|
+
:provider_job_id => provider_job_id,
|
16
|
+
:locale => locale,
|
17
|
+
})
|
11
18
|
raise exception
|
12
19
|
end
|
13
20
|
end
|
@@ -5,6 +5,7 @@ module Raven
|
|
5
5
|
INT_MASK = 0
|
6
6
|
DEFAULT_FIELDS = %w(authorization password passwd secret ssn social(.*)?sec)
|
7
7
|
CREDIT_CARD_RE = /^(?:\d[ -]*?){13,16}$/
|
8
|
+
REGEX_SPECIAL_CHARACTERS = %w(. $ ^ { [ ( | ) * + ?)
|
8
9
|
|
9
10
|
attr_accessor :sanitize_fields, :sanitize_credit_cards
|
10
11
|
|
@@ -23,7 +24,7 @@ module Raven
|
|
23
24
|
process(v)
|
24
25
|
elsif v.is_a?(Array)
|
25
26
|
v.map{|a| sanitize(k, a)}
|
26
|
-
elsif k == 'query_string'
|
27
|
+
elsif k.to_s == 'query_string'
|
27
28
|
sanitize_query_string(v)
|
28
29
|
elsif v.is_a?(Integer) && matches_regexes?(k,v)
|
29
30
|
INT_MASK
|
@@ -55,7 +56,17 @@ module Raven
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def fields_re
|
58
|
-
@fields_re ||=
|
59
|
+
@fields_re ||= /#{(DEFAULT_FIELDS | sanitize_fields).map do |f|
|
60
|
+
use_boundary?(f) ? "\\b#{f}\\b" : f
|
61
|
+
end.join("|")}/i
|
62
|
+
end
|
63
|
+
|
64
|
+
def use_boundary?(string)
|
65
|
+
!DEFAULT_FIELDS.include?(string) && !special_characters?(string)
|
66
|
+
end
|
67
|
+
|
68
|
+
def special_characters?(string)
|
69
|
+
REGEX_SPECIAL_CHARACTERS.select { |r| string.include?(r) }.any?
|
59
70
|
end
|
60
71
|
|
61
72
|
def parse_json_or_nil(string)
|
data/lib/raven/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'raven/base'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-raven
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.7.6
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: certifi
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,8 +144,9 @@ files:
|
|
158
144
|
- lib/raven/transports/http.rb
|
159
145
|
- lib/raven/transports/udp.rb
|
160
146
|
- lib/raven/version.rb
|
147
|
+
- lib/sentry-raven-without-integrations.rb
|
161
148
|
- lib/sentry-raven.rb
|
162
|
-
homepage:
|
149
|
+
homepage: https://github.com/getsentry/raven-ruby
|
163
150
|
licenses:
|
164
151
|
- Apache-2.0
|
165
152
|
metadata: {}
|
@@ -179,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
166
|
version: '0'
|
180
167
|
requirements: []
|
181
168
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.4.
|
169
|
+
rubygems_version: 2.4.6
|
183
170
|
signing_key:
|
184
171
|
specification_version: 4
|
185
172
|
summary: A gem that provides a client interface for the Sentry error logger
|