sentry-raven 2.7.4 → 2.12.3
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/.gitignore +0 -1
- data/.gitmodules +0 -3
- data/.rubocop.yml +1 -1
- data/.travis.yml +7 -7
- data/Gemfile +5 -5
- data/README.md +10 -6
- data/changelog.md +59 -0
- data/lib/raven/base.rb +2 -1
- data/lib/raven/breadcrumbs/logger.rb +1 -1
- data/lib/raven/client.rb +26 -6
- data/lib/raven/configuration.rb +45 -10
- data/lib/raven/event.rb +1 -18
- data/lib/raven/instance.rb +16 -4
- data/lib/raven/integrations/rails/controller_transaction.rb +1 -1
- data/lib/raven/processor/utf8conversion.rb +1 -1
- data/lib/raven/transports/stdout.rb +20 -0
- data/lib/raven/utils/exception_cause_chain.rb +19 -0
- data/lib/raven/version.rb +1 -1
- data/sentry-raven.gemspec +1 -2
- metadata +6 -20
- data/docs/Makefile +0 -130
- data/docs/breadcrumbs.rst +0 -51
- data/docs/conf.py +0 -228
- data/docs/config.rst +0 -260
- data/docs/context.rst +0 -141
- data/docs/index.rst +0 -113
- data/docs/install.rst +0 -40
- data/docs/integrations/heroku.rst +0 -11
- data/docs/integrations/index.rst +0 -59
- data/docs/integrations/puma.rst +0 -30
- data/docs/integrations/rack.rst +0 -27
- data/docs/integrations/rails.rst +0 -62
- data/docs/make.bat +0 -155
- data/docs/processors.rst +0 -124
- data/docs/sentry-doc-config.json +0 -31
- data/docs/usage.rst +0 -176
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86dc048eed812d93571e381134d4138c7eadd0f7
|
|
4
|
+
data.tar.gz: 70b6f8806383b20868acf609aed986160c8f31bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20b21e009d1ec5d1757fef8c8ff8e60dd663dfbfc5fc2cd173caed906f9e011ca496480d25076e9198d82855edb4d0b50ae9300cb4ec0f1cb102cb0e98987a05
|
|
7
|
+
data.tar.gz: 209abfc6bf093fd2640e76db98315673070d20069bfe5b52b5d4df24ff956caac1f3c6e7358be13bbfb3cd25d0a8863f99e328c42353bc78011fd417697fa617
|
data/.gitignore
CHANGED
data/.gitmodules
CHANGED
data/.rubocop.yml
CHANGED
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.
|
|
15
|
-
- 2.3.
|
|
16
|
-
- 2.4.
|
|
17
|
-
- 2.5.
|
|
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.
|
|
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.
|
|
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
|
-
<
|
|
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
|
[](https://rubygems.org/gems/sentry-raven)
|
|
8
11
|
[](https://travis-ci.org/getsentry/raven-ruby)
|
|
9
12
|
[](https://rubygems.org/gems/sentry-raven/)
|
|
13
|
+
[](https://dependabot.com/compatibility-score.html?dependency-name=sentry-raven&package-manager=bundler&version-scheme=semver)
|
|
10
14
|
|
|
11
15
|
|
|
12
|
-
[Documentation](https://docs.
|
|
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
|
|
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
|
|
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.
|
|
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
|
-
|
|
136
|
+
- [Discord](https://discord.gg/ez5KZN7)
|
data/changelog.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
2.12.3
|
|
2
|
+
----
|
|
3
|
+
|
|
4
|
+
*FIX: crash when Process.wait is used [@asBrettisay, #895]
|
|
5
|
+
|
|
6
|
+
2.12.2
|
|
7
|
+
----
|
|
8
|
+
|
|
9
|
+
* FIX: return tags/extra for [@rivayama, #931]
|
|
10
|
+
|
|
11
|
+
2.12.1
|
|
12
|
+
----
|
|
13
|
+
|
|
14
|
+
* FIX: undefined method `[]' for nil:NilClass [@HazAT, #932]
|
|
15
|
+
|
|
16
|
+
2.12.0
|
|
17
|
+
----
|
|
18
|
+
|
|
19
|
+
* FIX: Remove duplicate message when exception is emitted
|
|
20
|
+
* FIX: Frozen string bug in utf8conversation
|
|
21
|
+
* FEATURE: Allow block on tags_context and extra_context
|
|
22
|
+
|
|
23
|
+
2.11.3
|
|
24
|
+
----
|
|
25
|
+
|
|
26
|
+
* FIX: infinite backoff under pressure [@Bonias, #886]
|
|
27
|
+
|
|
28
|
+
2.11.2
|
|
29
|
+
----
|
|
30
|
+
|
|
31
|
+
* REF: Warn on 4xx error [@iloveitaly, #862]
|
|
32
|
+
|
|
33
|
+
2.11.1
|
|
34
|
+
----
|
|
35
|
+
|
|
36
|
+
* FIX: Call `to_s` on breadcrumb message [@halkeye, #914]
|
|
37
|
+
|
|
38
|
+
2.11.0
|
|
39
|
+
----
|
|
40
|
+
|
|
41
|
+
* FEATURE: Prepend the transaction around_action so libraries with controllers can alter the value. [@drcapulet, #887]
|
|
42
|
+
|
|
43
|
+
2.10.0
|
|
44
|
+
-----
|
|
45
|
+
|
|
46
|
+
* FEATURE: Added support for `SENTRY_ENVIRONMENT` [@mtsmfm, #910]
|
|
47
|
+
* FEATURE: Added support for `SENTRY_RELEASE` [@coorasse, #911]
|
|
48
|
+
|
|
49
|
+
2.9.0
|
|
50
|
+
-----
|
|
51
|
+
|
|
52
|
+
* FEATURE: Added `config.inspect_exception_causes_for_exclusion`. Determines if the exception cause should be inspected for `config.excluded_exceptions` option. [@effron, #872]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
2.8.0
|
|
56
|
+
-----
|
|
57
|
+
|
|
58
|
+
* 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]
|
|
59
|
+
|
|
1
60
|
2.7.4
|
|
2
61
|
-----
|
|
3
62
|
|
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
|
|
|
@@ -50,6 +56,8 @@ module Raven
|
|
|
50
56
|
case configuration.scheme
|
|
51
57
|
when 'http', 'https'
|
|
52
58
|
Transports::HTTP.new(configuration)
|
|
59
|
+
when 'stdout'
|
|
60
|
+
Transports::Stdout.new(configuration)
|
|
53
61
|
when 'dummy'
|
|
54
62
|
Transports::Dummy.new(configuration)
|
|
55
63
|
else
|
|
@@ -71,8 +79,20 @@ module Raven
|
|
|
71
79
|
end
|
|
72
80
|
end
|
|
73
81
|
|
|
82
|
+
def get_message_from_exception(event)
|
|
83
|
+
(
|
|
84
|
+
event &&
|
|
85
|
+
event[:exception] &&
|
|
86
|
+
event[:exception][:values] &&
|
|
87
|
+
event[:exception][:values][0] &&
|
|
88
|
+
event[:exception][:values][0][:type] &&
|
|
89
|
+
event[:exception][:values][0][:value] &&
|
|
90
|
+
"#{event[:exception][:values][0][:type]}: #{event[:exception][:values][0][:value]}"
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
74
94
|
def get_log_message(event)
|
|
75
|
-
(event && event[:message]) || '<no message value>'
|
|
95
|
+
(event && event[:message]) || get_message_from_exception(event) || '<no message value>'
|
|
76
96
|
end
|
|
77
97
|
|
|
78
98
|
def generate_auth_header
|
|
@@ -92,13 +112,13 @@ module Raven
|
|
|
92
112
|
end
|
|
93
113
|
|
|
94
114
|
def failed_send(e, event)
|
|
95
|
-
@state.failure
|
|
96
115
|
if e # exception was raised
|
|
97
|
-
|
|
116
|
+
@state.failure
|
|
117
|
+
configuration.logger.warn "Unable to record event with remote Sentry server (#{e.class} - #{e.message}):\n#{e.backtrace[0..10].join("\n")}"
|
|
98
118
|
else
|
|
99
|
-
configuration.logger.
|
|
119
|
+
configuration.logger.warn "Not sending event due to previous failure(s)."
|
|
100
120
|
end
|
|
101
|
-
configuration.logger.
|
|
121
|
+
configuration.logger.warn("Failed to submit event: #{get_log_message(event)}")
|
|
102
122
|
configuration.transport_failure_callback.call(event) if configuration.transport_failure_callback
|
|
103
123
|
end
|
|
104
124
|
end
|
data/lib/raven/configuration.rb
CHANGED
|
@@ -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
|
|
|
@@ -156,6 +160,15 @@ module Raven
|
|
|
156
160
|
# E.g. lambda { |event| Thread.new { MyJobProcessor.send_email(event) } }
|
|
157
161
|
attr_reader :transport_failure_callback
|
|
158
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
|
+
|
|
159
172
|
# Errors object - an Array that contains error messages. See #
|
|
160
173
|
attr_reader :errors
|
|
161
174
|
|
|
@@ -182,6 +195,9 @@ module Raven
|
|
|
182
195
|
Raven::Processor::HTTPHeaders
|
|
183
196
|
].freeze
|
|
184
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
|
+
|
|
185
201
|
LOG_PREFIX = "** [Raven] ".freeze
|
|
186
202
|
MODULE_SEPARATOR = "::".freeze
|
|
187
203
|
|
|
@@ -193,6 +209,7 @@ module Raven
|
|
|
193
209
|
self.environments = []
|
|
194
210
|
self.exclude_loggers = []
|
|
195
211
|
self.excluded_exceptions = IGNORE_DEFAULT.dup
|
|
212
|
+
self.inspect_exception_causes_for_exclusion = false
|
|
196
213
|
self.linecache = ::Raven::LineCache.new
|
|
197
214
|
self.logger = ::Raven::Logger.new(STDOUT)
|
|
198
215
|
self.open_timeout = 1
|
|
@@ -214,6 +231,7 @@ module Raven
|
|
|
214
231
|
self.tags = {}
|
|
215
232
|
self.timeout = 2
|
|
216
233
|
self.transport_failure_callback = false
|
|
234
|
+
self.before_send = false
|
|
217
235
|
end
|
|
218
236
|
|
|
219
237
|
def server=(value)
|
|
@@ -266,6 +284,13 @@ module Raven
|
|
|
266
284
|
@should_capture = value
|
|
267
285
|
end
|
|
268
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
|
+
|
|
269
294
|
# Allows config options to be read like a hash
|
|
270
295
|
#
|
|
271
296
|
# @param [Symbol] option Key for a given attribute
|
|
@@ -322,21 +347,32 @@ module Raven
|
|
|
322
347
|
end
|
|
323
348
|
|
|
324
349
|
def detect_release
|
|
325
|
-
|
|
350
|
+
detect_release_from_env ||
|
|
351
|
+
detect_release_from_git ||
|
|
326
352
|
detect_release_from_capistrano ||
|
|
327
353
|
detect_release_from_heroku
|
|
328
354
|
rescue => ex
|
|
329
355
|
logger.error "Error detecting release: #{ex.message}"
|
|
330
356
|
end
|
|
331
357
|
|
|
332
|
-
def excluded_exception?(
|
|
333
|
-
excluded_exceptions.any?
|
|
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
|
|
334
362
|
end
|
|
335
363
|
|
|
336
364
|
def get_exception_class(x)
|
|
337
365
|
x.is_a?(Module) ? x : qualified_const_get(x)
|
|
338
366
|
end
|
|
339
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
|
+
|
|
340
376
|
# In Ruby <2.0 const_get can't lookup "SomeModule::SomeClass" in one go
|
|
341
377
|
def qualified_const_get(x)
|
|
342
378
|
x = x.to_s
|
|
@@ -352,7 +388,7 @@ module Raven
|
|
|
352
388
|
def detect_release_from_heroku
|
|
353
389
|
return unless running_on_heroku?
|
|
354
390
|
return if ENV['CI']
|
|
355
|
-
logger.warn(
|
|
391
|
+
logger.warn(HEROKU_DYNO_METADATA_MESSAGE) && return unless ENV['HEROKU_SLUG_COMMIT']
|
|
356
392
|
|
|
357
393
|
ENV['HEROKU_SLUG_COMMIT']
|
|
358
394
|
end
|
|
@@ -361,11 +397,6 @@ module Raven
|
|
|
361
397
|
File.directory?("/etc/heroku")
|
|
362
398
|
end
|
|
363
399
|
|
|
364
|
-
def heroku_dyno_metadata_message
|
|
365
|
-
"You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's "\
|
|
366
|
-
"release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`"
|
|
367
|
-
end
|
|
368
|
-
|
|
369
400
|
def detect_release_from_capistrano
|
|
370
401
|
revision_file = File.join(project_root, 'REVISION')
|
|
371
402
|
revision_log = File.join(project_root, '..', 'revisions.log')
|
|
@@ -381,6 +412,10 @@ module Raven
|
|
|
381
412
|
Raven.sys_command("git rev-parse --short HEAD") if File.directory?(".git")
|
|
382
413
|
end
|
|
383
414
|
|
|
415
|
+
def detect_release_from_env
|
|
416
|
+
ENV['SENTRY_RELEASE']
|
|
417
|
+
end
|
|
418
|
+
|
|
384
419
|
def capture_in_current_environment?
|
|
385
420
|
return true unless environments.any? && !environments.include?(current_environment)
|
|
386
421
|
@errors << "Not configured to send/capture in environment '#{current_environment}'"
|
|
@@ -423,7 +458,7 @@ module Raven
|
|
|
423
458
|
end
|
|
424
459
|
|
|
425
460
|
def current_environment_from_env
|
|
426
|
-
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'
|
|
427
462
|
end
|
|
428
463
|
|
|
429
464
|
def server_name_from_env
|
data/lib/raven/event.rb
CHANGED
|
@@ -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 =
|
|
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|
|
|
@@ -237,20 +234,6 @@ module Raven
|
|
|
237
234
|
].map { |v| v.new(self) }
|
|
238
235
|
end
|
|
239
236
|
|
|
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
|
|
252
|
-
end
|
|
253
|
-
|
|
254
237
|
def list_gem_specs
|
|
255
238
|
# Older versions of Rubygems don't support iterating over all specs
|
|
256
239
|
Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map)
|
data/lib/raven/instance.rb
CHANGED
|
@@ -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
|
|
@@ -2,7 +2,7 @@ module Raven
|
|
|
2
2
|
class Rails
|
|
3
3
|
module ControllerTransaction
|
|
4
4
|
def self.included(base)
|
|
5
|
-
base.
|
|
5
|
+
base.prepend_around_action do |controller, block|
|
|
6
6
|
Raven.context.transaction.push "#{controller.class}##{controller.action_name}"
|
|
7
7
|
block.call
|
|
8
8
|
Raven.context.transaction.pop
|
|
@@ -39,7 +39,7 @@ module Raven
|
|
|
39
39
|
# https://github.com/rspec/rspec-support/blob/f0af3fd74a94ff7bb700f6ba06dbdc67bba17fbf/lib/rspec/support/encoded_string.rb#L120-L139
|
|
40
40
|
if String.method_defined?(:scrub) # 2.1+
|
|
41
41
|
def remove_invalid_bytes(string)
|
|
42
|
-
string.scrub
|
|
42
|
+
string.scrub(REPLACE)
|
|
43
43
|
end
|
|
44
44
|
else
|
|
45
45
|
def remove_invalid_bytes(string)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Raven
|
|
2
|
+
module Transports
|
|
3
|
+
class Stdout < Transport
|
|
4
|
+
attr_accessor :events
|
|
5
|
+
|
|
6
|
+
def initialize(*)
|
|
7
|
+
super
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def send_event(_auth_header, data, _options = {})
|
|
11
|
+
unless configuration.sending_allowed?
|
|
12
|
+
logger.debug("Event not sent: #{configuration.error_messages}")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
$stdout.puts data
|
|
16
|
+
$stdout.flush
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Raven
|
|
2
|
+
module Utils
|
|
3
|
+
module ExceptionCauseChain
|
|
4
|
+
def self.exception_to_array(exception)
|
|
5
|
+
if exception.respond_to?(:cause) && exception.cause
|
|
6
|
+
exceptions = [exception]
|
|
7
|
+
while exception.cause
|
|
8
|
+
exception = exception.cause
|
|
9
|
+
break if exceptions.any? { |e| e.object_id == exception.object_id }
|
|
10
|
+
exceptions << exception
|
|
11
|
+
end
|
|
12
|
+
exceptions
|
|
13
|
+
else
|
|
14
|
+
[exception]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/raven/version.rb
CHANGED
data/sentry-raven.gemspec
CHANGED
|
@@ -5,14 +5,13 @@ Gem::Specification.new do |gem|
|
|
|
5
5
|
gem.name = "sentry-raven"
|
|
6
6
|
gem.authors = ["Sentry Team"]
|
|
7
7
|
gem.description = gem.summary = "A gem that provides a client interface for the Sentry error logger"
|
|
8
|
-
gem.email = "
|
|
8
|
+
gem.email = "accounts@sentry.io"
|
|
9
9
|
gem.license = 'Apache-2.0'
|
|
10
10
|
gem.homepage = "https://github.com/getsentry/raven-ruby"
|
|
11
11
|
|
|
12
12
|
gem.version = Raven::VERSION
|
|
13
13
|
gem.platform = Gem::Platform::RUBY
|
|
14
14
|
gem.required_ruby_version = '>= 1.9.0'
|
|
15
|
-
gem.has_rdoc = true
|
|
16
15
|
gem.extra_rdoc_files = ["README.md", "LICENSE"]
|
|
17
16
|
gem.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
|
|
18
17
|
gem.bindir = "exe"
|