sentry-raven 2.7.3 → 2.13.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
- SHA1:
3
- metadata.gz: 400e642f148227a40dcf81d00af5513e2787b35c
4
- data.tar.gz: a4c90987e4d11f40234ada594208b109dccf4681
2
+ SHA256:
3
+ metadata.gz: 478a0cd677f1508fc2153381addf6956e189c5f9491ede8f79b6097977dd59b9
4
+ data.tar.gz: d87fe2f303acf7e1d8b658950a1e591800eaf8a0f8bbdd35637355ac6856f571
5
5
  SHA512:
6
- metadata.gz: 71ed2517a4a5a34397125108bbbac441a2b9aa2610684f70a2578e64a56775755373eef4369194605747a1498da3936e27fbbb4e3e78961edd102fec970bdbcb
7
- data.tar.gz: 3c33543e522a1f06f00967175c104fe515c71b60ce62994647e1d65c4d6fefcca56cabeb940450d08ca41c3384d48d0260fab1db378c260b438eae52b43258dd
6
+ metadata.gz: c83298b6f11a500e50f4e530de5421f32d15f7ea72d3a6aea18cd4330f832073a2000a68228b0237313e709b3e4adba570b140837256798ff3987b9eb0bb0fc9
7
+ data.tar.gz: 80405a6c1d1f99a7b65ed9491bd17c0d4143a5d5f212c6408988c9de329bc2bee2f2c6c1421d6134cc7f3d4c23ed2da06d0ba76509f6ae191f0236e83c53bdf8
data/.gitignore CHANGED
@@ -2,7 +2,6 @@ coverage
2
2
  pkg
3
3
  ruby/
4
4
  log/
5
- docs/_build
6
5
  .bundle
7
6
  *.gem
8
7
  gemfiles/*.lock
data/.gitmodules CHANGED
@@ -1,3 +0,0 @@
1
- [submodule "docs/_sentryext"]
2
- path = docs/_sentryext
3
- url = https://github.com/getsentry/sentry-doc-support
data/.rubocop.yml CHANGED
@@ -7,11 +7,11 @@ AllCops:
7
7
  - 'vendor/**/*'
8
8
 
9
9
  Metrics/ClassLength:
10
- Max: 268
10
+ Max: 300
11
11
  CountComments: false
12
12
 
13
13
  Metrics/AbcSize:
14
- Max: 30
14
+ Max: 40
15
15
 
16
16
  Metrics/CyclomaticComplexity:
17
17
  Max: 12
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  dist: trusty
3
- sudo: false
4
3
  group: beta
5
4
  cache: bundler
6
5
 
@@ -11,10 +10,11 @@ branches:
11
10
  only: [master]
12
11
 
13
12
  rvm:
14
- - 2.2.9
15
- - 2.3.6
16
- - 2.4.3
17
- - 2.5.0
13
+ - 2.2.10
14
+ - 2.3.8
15
+ - 2.4.9
16
+ - 2.5.7
17
+ - 2.6.5
18
18
 
19
19
  env:
20
20
  - RAILS_VERSION=4
@@ -37,9 +37,9 @@ matrix:
37
37
  env: RAILS_VERSION=4
38
38
  - rvm: jruby-1.7.27
39
39
  env: JRUBY_OPTS="--dev" RAILS_VERSION=4
40
- - rvm: jruby-9.1.15.0
40
+ - rvm: jruby-9.2.9.0
41
41
  env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=4
42
- - rvm: jruby-9.1.15.0
42
+ - rvm: jruby-9.2.9.0
43
43
  env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=5
44
44
  - rvm: ruby-head
45
45
  env: RAILS_VERSION=0
data/Gemfile CHANGED
@@ -4,12 +4,12 @@ gemspec
4
4
 
5
5
  if ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 4)
6
6
  gem "rails", "< 5"
7
- gem "rspec-rails"
7
+ gem "rspec-rails", "> 3"
8
8
  elsif ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 0)
9
9
  # no-op. No Rails.
10
10
  else
11
11
  gem "rails", "< 6"
12
- gem "rspec-rails"
12
+ gem "rspec-rails", "> 3"
13
13
  end
14
14
 
15
15
  if RUBY_VERSION < '2.0'
@@ -28,9 +28,9 @@ gem "pry-coolline"
28
28
  gem "benchmark-ips"
29
29
  gem "benchmark-ipsa" if RUBY_VERSION > '2.0'
30
30
  gem "ruby-prof", platform: :mri
31
- gem "rake"
32
- gem "rubocop", "~> 0.41.1"
33
- gem "rspec"
31
+ gem "rake", "> 12"
32
+ gem "rubocop", "~> 0.41.1" # Last version that supported 1.9, upgrade to 0.50 after we drop 1.9
33
+ gem "rspec", "> 3"
34
34
  gem "capybara" # rspec system tests
35
35
  gem "puma" # rspec system tests
36
36
 
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  <p align="center">
2
- <img src="https://cdn.rawgit.com/getsentry/raven-python/1e525422/docs/_static/logo.png">
2
+ <a href="https://sentry.io" target="_blank" align="center">
3
+ <img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4
+ </a>
5
+ <br>
3
6
  </p>
4
7
 
5
8
  # Raven-Ruby, the Ruby Client for Sentry
@@ -7,9 +10,10 @@
7
10
  [![Gem Version](https://img.shields.io/gem/v/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven)
8
11
  [![Build Status](https://img.shields.io/travis/getsentry/raven-ruby/master.svg)](https://travis-ci.org/getsentry/raven-ruby)
9
12
  [![Gem](https://img.shields.io/gem/dt/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven/)
13
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-raven&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-raven&package-manager=bundler&version-scheme=semver)
10
14
 
11
15
 
12
- [Documentation](https://docs.getsentry.com/hosted/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/raven-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
16
+ [Documentation](https://docs.sentry.io/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/raven-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
13
17
 
14
18
  The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
15
19
 
@@ -31,12 +35,12 @@ Raven will capture and send exceptions to the Sentry server whenever its DSN is
31
35
 
32
36
  ```bash
33
37
  # Set your SENTRY_DSN environment variable.
34
- export SENTRY_DSN=http://public:secret@example.com/project-id
38
+ export SENTRY_DSN=http://public@example.com/project-id
35
39
  ```
36
40
  ```ruby
37
41
  # Or you can configure the client in the code (not recommended - keep your DSN secret!)
38
42
  Raven.configure do |config|
39
- config.dsn = 'http://public:secret@example.com/project-id'
43
+ config.dsn = 'http://public@example.com/project-id'
40
44
  end
41
45
  ```
42
46
 
@@ -126,7 +130,7 @@ For more information, see [Context](https://docs.sentry.io/clients/ruby/context/
126
130
 
127
131
  ## More Information
128
132
 
129
- * [Documentation](https://docs.getsentry.com/hosted/clients/ruby/)
133
+ * [Documentation](https://docs.sentry.io/clients/ruby/)
130
134
  * [Bug Tracker](https://github.com/getsentry/raven-ruby/issues)
131
135
  * [Forum](https://forum.sentry.io/)
132
- * [IRC](irc://irc.freenode.net/sentry>) (irc.freenode.net, #sentry)
136
+ - [Discord](https://discord.gg/ez5KZN7)
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ begin
14
14
  require 'rubocop/rake_task'
15
15
  RuboCop::RakeTask.new(:rubocop) do |task|
16
16
  task.patterns = ['lib/**/*.rb','spec/**/*.rb',]
17
+ task.options << '--display-cop-names'
17
18
  end
18
19
 
19
20
  RSpec::Core::RakeTask.new(:spec) do |spec|
data/changelog.md CHANGED
@@ -1,3 +1,77 @@
1
+ 2.13.0
2
+ ----
3
+
4
+ * FIX: Sanitize event data before they are sent to async job. [@edariedl, #895]
5
+ * FIX: Serialization MongoDB ObjectId to JSON problem with gem delayed_job_mongoid conjunction. [@eagleas, #935]
6
+ * FEAT: Skip ActiveJob integration if there is a better one [@fsateler, #909]
7
+ * FIX: Bugs with send_event in asynchronous mode (#940) [@cstyles, #940]
8
+
9
+ 2.12.3
10
+ ----
11
+
12
+ * FIX: crash when Process.wait is used [@asBrettisay, #895]
13
+
14
+ 2.12.2
15
+ ----
16
+
17
+ * FIX: return tags/extra for [@rivayama, #931]
18
+
19
+ 2.12.1
20
+ ----
21
+
22
+ * FIX: undefined method `[]' for nil:NilClass [@HazAT, #932]
23
+
24
+ 2.12.0
25
+ ----
26
+
27
+ * FIX: Remove duplicate message when exception is emitted
28
+ * FIX: Frozen string bug in utf8conversation
29
+ * FEATURE: Allow block on tags_context and extra_context
30
+
31
+ 2.11.3
32
+ ----
33
+
34
+ * FIX: infinite backoff under pressure [@Bonias, #886]
35
+
36
+ 2.11.2
37
+ ----
38
+
39
+ * REF: Warn on 4xx error [@iloveitaly, #862]
40
+
41
+ 2.11.1
42
+ ----
43
+
44
+ * FIX: Call `to_s` on breadcrumb message [@halkeye, #914]
45
+
46
+ 2.11.0
47
+ ----
48
+
49
+ * FEATURE: Prepend the transaction around_action so libraries with controllers can alter the value. [@drcapulet, #887]
50
+
51
+ 2.10.0
52
+ -----
53
+
54
+ * FEATURE: Added support for `SENTRY_ENVIRONMENT` [@mtsmfm, #910]
55
+ * FEATURE: Added support for `SENTRY_RELEASE` [@coorasse, #911]
56
+
57
+ 2.9.0
58
+ -----
59
+
60
+ * FEATURE: Added `config.inspect_exception_causes_for_exclusion`. Determines if the exception cause should be inspected for `config.excluded_exceptions` option. [@effron, #872]
61
+
62
+
63
+ 2.8.0
64
+ -----
65
+
66
+ * FEATURE: Added `config.before_send`. Provide a lambda or proc to this config setting, which will be `call`ed before sending an event to Sentry. Receives `event` and `hint` as parameters. `hint` is a hash `{:exception => ex | nil, :message => message | nil}`. [@hazat, #882]
67
+
68
+ 2.7.4
69
+ -----
70
+
71
+ * BUGFIX: Correctly handle public only DSNs [@mitsuhiko, #847]
72
+ * BUGFIX: context attributes with nil raised error [@joker-777, 824]
73
+ * BUGFIX: Suppress warning about enabling dyno metadata in Heroku CI [@meganemura, #833]
74
+
1
75
  2.7.3
2
76
  -----
3
77
 
data/lib/raven/base.rb CHANGED
@@ -23,6 +23,7 @@ require 'raven/transports'
23
23
  require 'raven/transports/http'
24
24
  require 'raven/utils/deep_merge'
25
25
  require 'raven/utils/real_ip'
26
+ require 'raven/utils/exception_cause_chain'
26
27
  require 'raven/instance'
27
28
 
28
29
  require 'forwardable'
@@ -99,7 +100,7 @@ module Raven
99
100
 
100
101
  def sys_command(command)
101
102
  result = `#{command} 2>&1` rescue nil
102
- return if result.nil? || result.empty? || $CHILD_STATUS.exitstatus != 0
103
+ return if result.nil? || result.empty? || ($CHILD_STATUS && $CHILD_STATUS.exitstatus != 0)
103
104
  result.strip
104
105
  end
105
106
  end
@@ -36,7 +36,7 @@ module Raven
36
36
 
37
37
  # some loggers will add leading/trailing space as they (incorrectly, mind you)
38
38
  # think of logging as a shortcut to std{out,err}
39
- message = message.strip
39
+ message = message.to_s.strip
40
40
 
41
41
  last_crumb = Raven.breadcrumbs.peek
42
42
  # try to avoid dupes from logger broadcasts
data/lib/raven/client.rb CHANGED
@@ -18,9 +18,15 @@ module Raven
18
18
  @state = ClientState.new
19
19
  end
20
20
 
21
- def send_event(event)
21
+ def send_event(event, hint = nil)
22
22
  return false unless configuration.sending_allowed?(event)
23
23
 
24
+ event = configuration.before_send.call(event, hint) if configuration.before_send
25
+ if event.nil?
26
+ configuration.logger.info "Discarded event because before_send returned nil"
27
+ return
28
+ end
29
+
24
30
  # Convert to hash
25
31
  event = event.to_hash
26
32
 
@@ -29,7 +35,8 @@ module Raven
29
35
  return
30
36
  end
31
37
 
32
- configuration.logger.info "Sending event #{event[:event_id]} to Sentry"
38
+ event_id = event[:event_id] || event['event_id']
39
+ configuration.logger.info "Sending event #{event_id} to Sentry"
33
40
 
34
41
  content_type, encoded_data = encode(event)
35
42
 
@@ -50,6 +57,8 @@ module Raven
50
57
  case configuration.scheme
51
58
  when 'http', 'https'
52
59
  Transports::HTTP.new(configuration)
60
+ when 'stdout'
61
+ Transports::Stdout.new(configuration)
53
62
  when 'dummy'
54
63
  Transports::Dummy.new(configuration)
55
64
  else
@@ -71,8 +80,20 @@ module Raven
71
80
  end
72
81
  end
73
82
 
83
+ def get_message_from_exception(event)
84
+ (
85
+ event &&
86
+ event[:exception] &&
87
+ event[:exception][:values] &&
88
+ event[:exception][:values][0] &&
89
+ event[:exception][:values][0][:type] &&
90
+ event[:exception][:values][0][:value] &&
91
+ "#{event[:exception][:values][0][:type]}: #{event[:exception][:values][0][:value]}"
92
+ )
93
+ end
94
+
74
95
  def get_log_message(event)
75
- (event && event[:message]) || '<no message value>'
96
+ (event && event[:message]) || (event && event['message']) || get_message_from_exception(event) || '<no message value>'
76
97
  end
77
98
 
78
99
  def generate_auth_header
@@ -81,9 +102,9 @@ module Raven
81
102
  'sentry_version' => PROTOCOL_VERSION,
82
103
  'sentry_client' => USER_AGENT,
83
104
  'sentry_timestamp' => now,
84
- 'sentry_key' => configuration.public_key,
85
- 'sentry_secret' => configuration.secret_key
105
+ 'sentry_key' => configuration.public_key
86
106
  }
107
+ fields['sentry_secret'] = configuration.secret_key unless configuration.secret_key.nil?
87
108
  'Sentry ' + fields.map { |key, value| "#{key}=#{value}" }.join(', ')
88
109
  end
89
110
 
@@ -92,13 +113,13 @@ module Raven
92
113
  end
93
114
 
94
115
  def failed_send(e, event)
95
- @state.failure
96
116
  if e # exception was raised
97
- configuration.logger.error "Unable to record event with remote Sentry server (#{e.class} - #{e.message}):\n#{e.backtrace[0..10].join("\n")}"
117
+ @state.failure
118
+ configuration.logger.warn "Unable to record event with remote Sentry server (#{e.class} - #{e.message}):\n#{e.backtrace[0..10].join("\n")}"
98
119
  else
99
- configuration.logger.error "Not sending event due to previous failure(s)."
120
+ configuration.logger.warn "Not sending event due to previous failure(s)."
100
121
  end
101
- configuration.logger.error("Failed to submit event: #{get_log_message(event)}")
122
+ configuration.logger.warn("Failed to submit event: #{get_log_message(event)}")
102
123
  configuration.transport_failure_callback.call(event) if configuration.transport_failure_callback
103
124
  end
104
125
  end
@@ -31,6 +31,10 @@ module Raven
31
31
  # You should probably append to this rather than overwrite it.
32
32
  attr_accessor :excluded_exceptions
33
33
 
34
+ # Boolean to check nested exceptions when deciding if to exclude. Defaults to false
35
+ attr_accessor :inspect_exception_causes_for_exclusion
36
+ alias inspect_exception_causes_for_exclusion? inspect_exception_causes_for_exclusion
37
+
34
38
  # DSN component - set automatically if DSN provided
35
39
  attr_accessor :host
36
40
 
@@ -116,6 +120,8 @@ module Raven
116
120
 
117
121
  # Secret key for authentication with the Sentry server
118
122
  # If you provide a DSN, this will be set automatically.
123
+ #
124
+ # This is deprecated and not necessary for newer Sentry installations any more.
119
125
  attr_accessor :secret_key
120
126
 
121
127
  # Include module versions in reports - boolean.
@@ -154,6 +160,15 @@ module Raven
154
160
  # E.g. lambda { |event| Thread.new { MyJobProcessor.send_email(event) } }
155
161
  attr_reader :transport_failure_callback
156
162
 
163
+ # Optional Proc, called before sending an event to the server/
164
+ # E.g.: lambda { |event, hint| event }
165
+ # E.g.: lambda { |event, hint| nil }
166
+ # E.g.: lambda { |event, hint|
167
+ # event[:message] = 'a'
168
+ # event
169
+ # }
170
+ attr_reader :before_send
171
+
157
172
  # Errors object - an Array that contains error messages. See #
158
173
  attr_reader :errors
159
174
 
@@ -180,6 +195,9 @@ module Raven
180
195
  Raven::Processor::HTTPHeaders
181
196
  ].freeze
182
197
 
198
+ HEROKU_DYNO_METADATA_MESSAGE = "You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's "\
199
+ "release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`".freeze
200
+
183
201
  LOG_PREFIX = "** [Raven] ".freeze
184
202
  MODULE_SEPARATOR = "::".freeze
185
203
 
@@ -191,6 +209,7 @@ module Raven
191
209
  self.environments = []
192
210
  self.exclude_loggers = []
193
211
  self.excluded_exceptions = IGNORE_DEFAULT.dup
212
+ self.inspect_exception_causes_for_exclusion = false
194
213
  self.linecache = ::Raven::LineCache.new
195
214
  self.logger = ::Raven::Logger.new(STDOUT)
196
215
  self.open_timeout = 1
@@ -212,6 +231,7 @@ module Raven
212
231
  self.tags = {}
213
232
  self.timeout = 2
214
233
  self.transport_failure_callback = false
234
+ self.before_send = false
215
235
  end
216
236
 
217
237
  def server=(value)
@@ -223,7 +243,7 @@ module Raven
223
243
  # DSN-style string
224
244
  self.project_id = uri_path.pop
225
245
  self.public_key = uri.user
226
- self.secret_key = uri.password
246
+ self.secret_key = !(uri.password.nil? || uri.password.empty?) ? uri.password : nil
227
247
  end
228
248
 
229
249
  self.scheme = uri.scheme
@@ -264,6 +284,13 @@ module Raven
264
284
  @should_capture = value
265
285
  end
266
286
 
287
+ def before_send=(value)
288
+ unless value == false || value.respond_to?(:call)
289
+ raise ArgumentError, "before_send must be callable (or false to disable)"
290
+ end
291
+ @before_send = value
292
+ end
293
+
267
294
  # Allows config options to be read like a hash
268
295
  #
269
296
  # @param [Symbol] option Key for a given attribute
@@ -320,21 +347,32 @@ module Raven
320
347
  end
321
348
 
322
349
  def detect_release
323
- detect_release_from_git ||
350
+ detect_release_from_env ||
351
+ detect_release_from_git ||
324
352
  detect_release_from_capistrano ||
325
353
  detect_release_from_heroku
326
354
  rescue => ex
327
355
  logger.error "Error detecting release: #{ex.message}"
328
356
  end
329
357
 
330
- def excluded_exception?(exc)
331
- excluded_exceptions.any? { |x| get_exception_class(x) === exc }
358
+ def excluded_exception?(incoming_exception)
359
+ excluded_exceptions.any? do |excluded_exception|
360
+ matches_exception?(get_exception_class(excluded_exception), incoming_exception)
361
+ end
332
362
  end
333
363
 
334
364
  def get_exception_class(x)
335
365
  x.is_a?(Module) ? x : qualified_const_get(x)
336
366
  end
337
367
 
368
+ def matches_exception?(excluded_exception_class, incoming_exception)
369
+ if inspect_exception_causes_for_exclusion?
370
+ Raven::Utils::ExceptionCauseChain.exception_to_array(incoming_exception).any? { |cause| excluded_exception_class === cause }
371
+ else
372
+ excluded_exception_class === incoming_exception
373
+ end
374
+ end
375
+
338
376
  # In Ruby <2.0 const_get can't lookup "SomeModule::SomeClass" in one go
339
377
  def qualified_const_get(x)
340
378
  x = x.to_s
@@ -349,7 +387,8 @@ module Raven
349
387
 
350
388
  def detect_release_from_heroku
351
389
  return unless running_on_heroku?
352
- logger.warn(heroku_dyno_metadata_message) && return unless ENV['HEROKU_SLUG_COMMIT']
390
+ return if ENV['CI']
391
+ logger.warn(HEROKU_DYNO_METADATA_MESSAGE) && return unless ENV['HEROKU_SLUG_COMMIT']
353
392
 
354
393
  ENV['HEROKU_SLUG_COMMIT']
355
394
  end
@@ -358,11 +397,6 @@ module Raven
358
397
  File.directory?("/etc/heroku")
359
398
  end
360
399
 
361
- def heroku_dyno_metadata_message
362
- "You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's "\
363
- "release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`"
364
- end
365
-
366
400
  def detect_release_from_capistrano
367
401
  revision_file = File.join(project_root, 'REVISION')
368
402
  revision_log = File.join(project_root, '..', 'revisions.log')
@@ -378,6 +412,10 @@ module Raven
378
412
  Raven.sys_command("git rev-parse --short HEAD") if File.directory?(".git")
379
413
  end
380
414
 
415
+ def detect_release_from_env
416
+ ENV['SENTRY_RELEASE']
417
+ end
418
+
381
419
  def capture_in_current_environment?
382
420
  return true unless environments.any? && !environments.include?(current_environment)
383
421
  @errors << "Not configured to send/capture in environment '#{current_environment}'"
@@ -391,9 +429,9 @@ module Raven
391
429
  end
392
430
 
393
431
  def valid?
394
- return true if %w(server host path public_key secret_key project_id).all? { |k| public_send(k) }
432
+ return true if %w(server host path public_key project_id).all? { |k| public_send(k) }
395
433
  if server
396
- %w(server host path public_key secret_key project_id).map do |key|
434
+ %w(server host path public_key project_id).map do |key|
397
435
  @errors << "No #{key} specified" unless public_send(key)
398
436
  end
399
437
  else
@@ -420,7 +458,7 @@ module Raven
420
458
  end
421
459
 
422
460
  def current_environment_from_env
423
- ENV['SENTRY_CURRENT_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default'
461
+ ENV['SENTRY_CURRENT_ENV'] || ENV['SENTRY_ENVIRONMENT'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default'
424
462
  end
425
463
 
426
464
  def server_name_from_env
data/lib/raven/event.rb CHANGED
@@ -39,7 +39,7 @@ module Raven
39
39
 
40
40
  # Allow attributes to be set on the event at initialization
41
41
  yield self if block_given?
42
- init.each_pair { |key, val| public_send("#{key}=", val) }
42
+ init.each_pair { |key, val| public_send("#{key}=", val) unless val.nil? }
43
43
 
44
44
  set_core_attributes_from_configuration
45
45
  set_core_attributes_from_context
@@ -59,10 +59,7 @@ module Raven
59
59
  return unless configuration.exception_class_allowed?(exc)
60
60
 
61
61
  new(options) do |evt|
62
- evt.message = "#{exc.class}: #{exc.message}"
63
-
64
62
  evt.add_exception_interface(exc)
65
-
66
63
  yield evt if block
67
64
  end
68
65
  end
@@ -139,7 +136,7 @@ module Raven
139
136
 
140
137
  def add_exception_interface(exc)
141
138
  interface(:exception) do |exc_int|
142
- exceptions = exception_chain_to_array(exc)
139
+ exceptions = Raven::Utils::ExceptionCauseChain.exception_to_array(exc).reverse
143
140
  backtraces = Set.new
144
141
  exc_int.values = exceptions.map do |e|
145
142
  SingleExceptionInterface.new do |int|
@@ -231,24 +228,7 @@ module Raven
231
228
  end
232
229
 
233
230
  def async_json_processors
234
- [
235
- Raven::Processor::RemoveCircularReferences,
236
- Raven::Processor::UTF8Conversion
237
- ].map { |v| v.new(self) }
238
- end
239
-
240
- def exception_chain_to_array(exc)
241
- if exc.respond_to?(:cause) && exc.cause
242
- exceptions = [exc]
243
- while exc.cause
244
- exc = exc.cause
245
- break if exceptions.any? { |e| e.object_id == exc.object_id }
246
- exceptions << exc
247
- end
248
- exceptions.reverse!
249
- else
250
- [exc]
251
- end
231
+ configuration.processors.map { |v| v.new(self) }
252
232
  end
253
233
 
254
234
  def list_gem_specs
@@ -77,8 +77,8 @@ module Raven
77
77
  # @example
78
78
  # evt = Raven::Event.new(:message => "An error")
79
79
  # Raven.send_event(evt)
80
- def send_event(event)
81
- client.send_event(event)
80
+ def send_event(event, hint = nil)
81
+ client.send_event(event, hint)
82
82
  end
83
83
 
84
84
  # Capture and process any exceptions from the given block.
@@ -120,10 +120,10 @@ module Raven
120
120
  configuration.async.call(evt.to_json_compatible)
121
121
  rescue => ex
122
122
  logger.error("async event sending failed: #{ex.message}")
123
- send_event(evt)
123
+ send_event(evt, make_hint(obj))
124
124
  end
125
125
  else
126
- send_event(evt)
126
+ send_event(evt, make_hint(obj))
127
127
  end
128
128
  Thread.current["sentry_#{object_id}_last_event_id".to_sym] = evt.id
129
129
  evt
@@ -183,6 +183,10 @@ module Raven
183
183
  # Raven.tags_context('my_custom_tag' => 'tag_value')
184
184
  def tags_context(options = nil)
185
185
  context.tags.merge!(options || {})
186
+ yield if block_given?
187
+ context.tags
188
+ ensure
189
+ context.tags.delete_if { |k, _| options.keys.include? k } if block_given?
186
190
  end
187
191
 
188
192
  # Bind extra context. Merges with existing context (if any).
@@ -194,6 +198,10 @@ module Raven
194
198
  # Raven.extra_context('my_custom_data' => 'value')
195
199
  def extra_context(options = nil)
196
200
  context.extra.merge!(options || {})
201
+ yield if block_given?
202
+ context.extra
203
+ ensure
204
+ context.extra.delete_if { |k, _| options.keys.include? k } if block_given?
197
205
  end
198
206
 
199
207
  def rack_context(env)
@@ -217,5 +225,9 @@ module Raven
217
225
  end
218
226
  end
219
227
  end
228
+
229
+ def make_hint(obj)
230
+ obj.is_a?(String) ? { :exception => nil, :message => obj } : { :exception => obj, :message => nil }
231
+ end
220
232
  end
221
233
  end
@@ -13,7 +13,7 @@ module Delayed
13
13
  # Log error to Sentry
14
14
  extra = {
15
15
  :delayed_job => {
16
- :id => job.id,
16
+ :id => job.id.to_s,
17
17
  :priority => job.priority,
18
18
  :attempts => job.attempts,
19
19
  :run_at => job.run_at,
@@ -36,7 +36,7 @@ module Delayed
36
36
  :logger => 'delayed_job',
37
37
  :tags => {
38
38
  :delayed_job_queue => job.queue,
39
- :delayed_job_id => job.id
39
+ :delayed_job_id => job.id.to_s
40
40
  },
41
41
  :extra => extra)
42
42
 
@@ -9,7 +9,11 @@ module Raven
9
9
  def self.included(base)
10
10
  base.class_eval do
11
11
  around_perform do |job, block|
12
- capture_and_reraise_with_sentry(job, block)
12
+ if already_supported_by_specific_integration?(job)
13
+ block.call
14
+ else
15
+ capture_and_reraise_with_sentry(job, block)
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -18,9 +22,7 @@ module Raven
18
22
  block.call
19
23
  rescue Exception => exception # rubocop:disable Lint/RescueException
20
24
  return if rescue_with_handler(exception)
21
- unless already_supported_by_specific_integration?(job)
22
- Raven.capture_exception(exception, :extra => raven_context(job))
23
- end
25
+ Raven.capture_exception(exception, :extra => raven_context(job))
24
26
  raise exception
25
27
  ensure
26
28
  Context.clear!