sentry-raven 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69cb623c7ac9a07889b6ae03ec5444319e191f8f
4
- data.tar.gz: 8369bebd8ccf68813e9b036efe138d8dfbde4bac
3
+ metadata.gz: dccadb5ecbfd08ce2f10b61d81cfde82d980751e
4
+ data.tar.gz: fa8760022edb8215192bc6d2a2317443dd0d5822
5
5
  SHA512:
6
- metadata.gz: e1ba87c6185709d7933339e40688a0aa4eba22e9377dd37e97e480ead398102d3b058d6cc64af1dc3baeb4f1a5bfb1f630926a49a6030844981f2497888c4516
7
- data.tar.gz: 389740e37e3f9e47f7ba50794278e1f656e68cc85f18cefdfd8f07fd4d4ddc15f1b775767d17655c978cc1a348ed3c646e12dc2047fb86f1cddd6e78fe7592d7
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](http://github.com/getsentry/raven-ruby/issues>)
51
- * [Code](http://github.com/getsentry/raven-ruby>)
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
- available_integrations = %w[delayed_job railties sidekiq rack rake]
207
- integrations_to_load = available_integrations & Gem.loaded_specs.keys
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
- begin
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 $ERROR_INFO
232
- logger.debug "Caught a post-mortem exception: #{$ERROR_INFO.inspect}"
233
- capture_exception($ERROR_INFO, options)
249
+ if $!
250
+ logger.debug "Caught a post-mortem exception: #{$!.inspect}"
251
+ capture_exception($!, options)
234
252
  end
235
253
  end
236
254
  end
@@ -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 = 'root'
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 => { :active_job => self.class.name })
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 ||= /(#{(DEFAULT_FIELDS | sanitize_fields).join("|")})/i
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
@@ -1,3 +1,3 @@
1
1
  module Raven
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
@@ -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.14.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-07-16 00:00:00.000000000 Z
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: http://github.com/getsentry/raven-ruby
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.8
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