sentry-raven 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/raven/base.rb +14 -1
- data/lib/raven/event.rb +3 -1
- data/lib/raven/integrations/rack.rb +7 -7
- data/lib/raven/integrations/rails.rb +14 -9
- data/lib/raven/integrations/rails/{middleware → overrides}/debug_exceptions_catcher.rb +1 -1
- data/lib/raven/integrations/rails/overrides/streaming_reporter.rb +23 -0
- data/lib/raven/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35bfb0236a3a8236cfe5c2ad37592f973c9612be
|
4
|
+
data.tar.gz: 79ee56bfc0b8243f4dd50111aa253498950548a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3caa9d91239b8f4bb0355f5a0bf6ea5af48e616e91f43a7abdc62f91f65638f0fca6d73dfeb63be6ba610b40a4c2defa23ca40e2256c1a8f5ad5dfd1ea5d137
|
7
|
+
data.tar.gz: 1cbeccc7169fba6eef992a6eb11d5c6bd8ec6aef89a780c200cb10f011a4bf970109aac68c870975f44a80849e428316382969d92ea70b300278ebe3485cf310
|
data/lib/raven/base.rb
CHANGED
@@ -115,13 +115,17 @@ module Raven
|
|
115
115
|
else
|
116
116
|
send_event(evt)
|
117
117
|
end
|
118
|
-
|
118
|
+
Thread.current[:sentry_last_event_id] = evt.id
|
119
119
|
evt
|
120
120
|
end
|
121
121
|
end
|
122
122
|
alias_method :capture_message, :capture_type
|
123
123
|
alias_method :capture_exception, :capture_type
|
124
124
|
|
125
|
+
def last_event_id
|
126
|
+
Thread.current[:sentry_last_event_id]
|
127
|
+
end
|
128
|
+
|
125
129
|
def should_capture?(message_or_exc)
|
126
130
|
if configuration.should_capture
|
127
131
|
configuration.should_capture.call(*[message_or_exc])
|
@@ -228,6 +232,15 @@ module Raven
|
|
228
232
|
self.logger.warn "Unable to load raven/integrations/#{integration}: #{error}"
|
229
233
|
end
|
230
234
|
|
235
|
+
def rails_safely_prepend(module_name, opts = {})
|
236
|
+
return if opts[:to].nil?
|
237
|
+
if opts[:to].respond_to?(:prepend, true)
|
238
|
+
opts[:to].send(:prepend, Raven::Rails::Overrides.const_get(module_name))
|
239
|
+
else
|
240
|
+
opts[:to].send(:include, Raven::Rails::Overrides.const_get("Old" + module_name))
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
231
244
|
# For cross-language compat
|
232
245
|
alias :captureException :capture_exception
|
233
246
|
alias :captureMessage :capture_message
|
data/lib/raven/event.rb
CHANGED
@@ -127,6 +127,7 @@ module Raven
|
|
127
127
|
evt.interface(:exception) do |exc_int|
|
128
128
|
exceptions = [exc]
|
129
129
|
context = Set.new [exc.object_id]
|
130
|
+
backtraces = Set.new
|
130
131
|
|
131
132
|
while exc.respond_to?(:cause) && exc.cause
|
132
133
|
exc = exc.cause
|
@@ -145,7 +146,8 @@ module Raven
|
|
145
146
|
int.module = e.class.to_s.split('::')[0...-1].join('::')
|
146
147
|
|
147
148
|
int.stacktrace =
|
148
|
-
if e.backtrace
|
149
|
+
if e.backtrace && !backtraces.include?(e.backtrace.object_id)
|
150
|
+
backtraces << e.backtrace.object_id
|
149
151
|
StacktraceInterface.new do |stacktrace|
|
150
152
|
stacktrace_interface_from(stacktrace, evt, e.backtrace)
|
151
153
|
end
|
@@ -96,19 +96,19 @@ module Raven
|
|
96
96
|
key = key.to_s # rack env can contain symbols
|
97
97
|
value = value.to_s
|
98
98
|
next unless key.upcase == key # Non-upper case stuff isn't either
|
99
|
+
|
99
100
|
# Rack adds in an incorrect HTTP_VERSION key, which causes downstream
|
100
101
|
# to think this is a Version header. Instead, this is mapped to
|
101
102
|
# env['SERVER_PROTOCOL']. But we don't want to ignore a valid header
|
102
103
|
# if the request has legitimately sent a Version header themselves.
|
103
104
|
# See: https://github.com/rack/rack/blob/028438f/lib/rack/handler/cgi.rb#L29
|
104
105
|
next if key == 'HTTP_VERSION' && value == ENV['SERVER_PROTOCOL']
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
106
|
+
|
107
|
+
next unless key.start_with?('HTTP_') || %w(CONTENT_TYPE CONTENT_LENGTH).include?(key)
|
108
|
+
# Rack stores headers as HTTP_WHAT_EVER, we need What-Ever
|
109
|
+
key = key.gsub("HTTP_", "")
|
110
|
+
key = key.split('_').map(&:capitalize).join('-')
|
111
|
+
memo[key] = value
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -2,14 +2,25 @@ require 'rails'
|
|
2
2
|
|
3
3
|
module Raven
|
4
4
|
class Rails < ::Rails::Railtie
|
5
|
+
require 'raven/integrations/rails/overrides/streaming_reporter'
|
6
|
+
require 'raven/integrations/rails/controller_methods'
|
7
|
+
|
5
8
|
initializer "raven.use_rack_middleware" do |app|
|
6
9
|
app.config.middleware.insert 0, Raven::Rack
|
7
10
|
end
|
8
11
|
|
9
12
|
initializer 'raven.action_controller' do
|
10
13
|
ActiveSupport.on_load :action_controller do
|
11
|
-
require 'raven/integrations/rails/controller_methods'
|
12
14
|
include Raven::Rails::ControllerMethods
|
15
|
+
if ::Rails::VERSION::STRING >= "4.0.0"
|
16
|
+
Raven.rails_safely_prepend("StreamingReporter", :to => ActionController::Live)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
initializer 'raven.action_view' do
|
22
|
+
ActiveSupport.on_load :action_view do
|
23
|
+
Raven.rails_safely_prepend("StreamingReporter", :to => ActionView::StreamingTemplateRenderer::Body)
|
13
24
|
end
|
14
25
|
end
|
15
26
|
|
@@ -23,19 +34,13 @@ module Raven
|
|
23
34
|
|
24
35
|
config.after_initialize do
|
25
36
|
if Raven.configuration.rails_report_rescued_exceptions
|
26
|
-
require 'raven/integrations/rails/
|
37
|
+
require 'raven/integrations/rails/overrides/debug_exceptions_catcher'
|
27
38
|
if defined?(::ActionDispatch::DebugExceptions)
|
28
39
|
exceptions_class = ::ActionDispatch::DebugExceptions
|
29
40
|
elsif defined?(::ActionDispatch::ShowExceptions)
|
30
41
|
exceptions_class = ::ActionDispatch::ShowExceptions
|
31
42
|
end
|
32
|
-
|
33
|
-
if exceptions_class.respond_to?(:prepend, true)
|
34
|
-
exceptions_class.send(:prepend, Raven::Rails::Middleware::DebugExceptionsCatcher)
|
35
|
-
else
|
36
|
-
exceptions_class.send(:include, Raven::Rails::Middleware::OldDebugExceptionsCatcher)
|
37
|
-
end
|
38
|
-
end
|
43
|
+
Raven.rails_safely_prepend("DebugExceptionsCatcher", :to => exceptions_class)
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Raven
|
2
|
+
class Rails
|
3
|
+
module Overrides
|
4
|
+
module StreamingReporter
|
5
|
+
def log_error(exception)
|
6
|
+
Raven.capture_exception(exception)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module OldStreamingReporter
|
12
|
+
def self.included(base)
|
13
|
+
base.send(:alias_method_chain, :log_error, :raven)
|
14
|
+
end
|
15
|
+
|
16
|
+
def log_error_with_raven(exception)
|
17
|
+
Raven.capture_exception(exception)
|
18
|
+
log_error_without_raven(exception)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/raven/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.1.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: 2016-
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -160,7 +160,8 @@ files:
|
|
160
160
|
- lib/raven/integrations/rails.rb
|
161
161
|
- lib/raven/integrations/rails/active_job.rb
|
162
162
|
- lib/raven/integrations/rails/controller_methods.rb
|
163
|
-
- lib/raven/integrations/rails/
|
163
|
+
- lib/raven/integrations/rails/overrides/debug_exceptions_catcher.rb
|
164
|
+
- lib/raven/integrations/rails/overrides/streaming_reporter.rb
|
164
165
|
- lib/raven/integrations/railties.rb
|
165
166
|
- lib/raven/integrations/rake.rb
|
166
167
|
- lib/raven/integrations/sidekiq.rb
|