raygun-apm-rails 1.0.15 → 1.0.20
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/CHANGELOG.rdoc +18 -0
- data/lib/raygun/apm/rails.rb +10 -0
- data/lib/raygun/apm/rails/middleware.rb +47 -23
- data/lib/raygun/apm/rails/railtie.rb +4 -0
- data/lib/raygun/apm/rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 274ea9a538eec6a7f3b33798485bb8a34e125d6b7656f6da6190b137d2a50667
|
4
|
+
data.tar.gz: e3083172f595177fbcca74e9206bb241c17f703e532ffb7c16d18322b75218a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ab24ef63ac928dc823e96181a1b1f5be51839f4b13646b07571686680eea2482dbedd0134e4959bcd4233d07ca8e6f80883308ba67922e11a2e77f3a9a9c9b5
|
7
|
+
data.tar.gz: '0988caffa77325919b9fb2d3d31bbc90229ecf424bc52686980f3c5a6953d9e67f54407f02550acc8073e118296512a372ffb476e032bdc471cd02b0b3d17322'
|
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
== 1.0.20 (March 18, 2020)
|
4
|
+
|
5
|
+
* Introduce support for detecting the presence of raygun4ruby and integrate better with the exception tracker
|
6
|
+
|
7
|
+
== 1.0.19 (March 16, 2020)
|
8
|
+
|
9
|
+
* Improve trace emission of unhandled exceptions in a request context
|
10
|
+
|
11
|
+
== 1.0.18 (March 15, 2020)
|
12
|
+
|
13
|
+
* Ensure a better experience with raygun4ruby with only Raygun::track_exception whitelisted
|
14
|
+
* Remove the warning on a HTTP IN event with an exception payload - spams STDOUT and already confused some testers
|
15
|
+
* Ensure errors raised during request exception always result in a fully wrapped trace with a 500 status
|
16
|
+
* Wrap the exceptional HTTP IN error handler in a fake user code method too to get past the agent gate for that
|
17
|
+
* Prefer the singleton interface on the Tracer
|
18
|
+
* Blacklist HTTParty
|
data/lib/raygun/apm/rails.rb
CHANGED
@@ -67,8 +67,18 @@ module Raygun
|
|
67
67
|
Nokogiri
|
68
68
|
Loofah
|
69
69
|
WebConsole
|
70
|
+
HTTParty
|
71
|
+
Raygun::Breadcrumbs
|
72
|
+
Raygun::Configuration
|
73
|
+
Raygun::config
|
70
74
|
+Raygun::Apm::Rails::Middleware::Ruby_APM_profiler_trace
|
75
|
+
+Raygun::Apm::Rails::Middleware::Ruby_APM_request_error
|
76
|
+
+Raygun::track_exception
|
71
77
|
}
|
78
|
+
|
79
|
+
def self.raygun4ruby?
|
80
|
+
defined?(Raygun) && Raygun.respond_to?(:configured?) && Raygun.configured?
|
81
|
+
end
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
@@ -4,23 +4,7 @@ module Raygun
|
|
4
4
|
class Middleware
|
5
5
|
def initialize(app)
|
6
6
|
@app = app
|
7
|
-
@tracer =
|
8
|
-
@tracer.udp_sink!
|
9
|
-
@tracer.process_started
|
10
|
-
ObjectSpace.define_finalizer(self, self.class.finalize(@tracer))
|
11
|
-
|
12
|
-
@http_in_subscriber = ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
13
|
-
http_in_handler(args)
|
14
|
-
end
|
15
|
-
|
16
|
-
@sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
17
|
-
sql_handler(args)
|
18
|
-
end
|
19
|
-
|
20
|
-
GC.stress = true if ENV['RAYGUN_STRESS_GC']
|
21
|
-
# If any fatal errors on init, shutdown the tracer
|
22
|
-
rescue Raygun::Apm::FatalError => e
|
23
|
-
raygun_shutdown_handler(e)
|
7
|
+
@tracer = nil
|
24
8
|
end
|
25
9
|
|
26
10
|
def call(env)
|
@@ -33,23 +17,57 @@ module Raygun
|
|
33
17
|
def instrument(env)
|
34
18
|
res = nil
|
35
19
|
# Can be nil if we had a fatal error
|
20
|
+
@tracer ||= Raygun::Apm::Tracer.instance || init_tracer
|
36
21
|
if @tracer
|
37
22
|
# For the exceptional HTTP IN handler
|
38
23
|
@request_started = @tracer.now
|
39
|
-
Thread.current.thread_variable_set(:_raygun_apm_tracer, @tracer)
|
40
24
|
@tracer.start_trace
|
41
25
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
26
|
+
exception = nil
|
27
|
+
res = nil
|
28
|
+
Ruby_APM_profiler_trace do
|
29
|
+
begin
|
30
|
+
res = @app.call(env)
|
31
|
+
rescue => e
|
32
|
+
Ruby_APM_request_error do
|
33
|
+
Raygun.track_exception(e, env) if Raygun::Apm::Rails.raygun4ruby?
|
34
|
+
exceptional_http_in_handler(env, 500)
|
35
|
+
end
|
36
|
+
exection = e
|
37
|
+
end
|
38
|
+
end
|
39
|
+
if res && (status = res.first) >= 400 && status < 600
|
40
|
+
Ruby_APM_request_error { exceptional_http_in_handler(env, status) }
|
45
41
|
end
|
46
42
|
# Can be nil if we had a fatal error
|
47
43
|
@tracer.end_trace if @tracer
|
44
|
+
raise exception if exception
|
48
45
|
res
|
49
46
|
rescue Raygun::Apm::FatalError => e
|
50
47
|
raygun_shutdown_handler(e)
|
51
48
|
end
|
52
49
|
|
50
|
+
def init_tracer
|
51
|
+
tracer = Raygun::Apm::Tracer.new
|
52
|
+
tracer.udp_sink!
|
53
|
+
tracer.process_started
|
54
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(tracer))
|
55
|
+
|
56
|
+
@http_in_subscriber = ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
57
|
+
http_in_handler(args)
|
58
|
+
end
|
59
|
+
|
60
|
+
@sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
61
|
+
sql_handler(args)
|
62
|
+
end
|
63
|
+
|
64
|
+
GC.stress = true if ENV['RAYGUN_STRESS_GC']
|
65
|
+
Raygun::Apm::Tracer.instance = tracer
|
66
|
+
# If any fatal errors on init, shutdown the tracer
|
67
|
+
rescue Raygun::Apm::FatalError => e
|
68
|
+
raygun_shutdown_handler(e)
|
69
|
+
end
|
70
|
+
|
53
71
|
def raygun_shutdown_handler(exception)
|
54
72
|
warn "[Raygun APM] shutting down due to error - #{exception.message} #{exception.backtrace.join("\n")}",
|
55
73
|
# Kill extended event subcriptions
|
@@ -57,13 +75,15 @@ module Raygun
|
|
57
75
|
ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
|
58
76
|
warn "[Raygun APM] notification hooks unsubscribed"
|
59
77
|
# Let the GC clean up the sink thread through the finalizer below
|
60
|
-
@tracer = nil
|
61
|
-
Thread.current.thread_variable_set(:_raygun_apm_tracer, nil)
|
78
|
+
@tracer = Raygun::Apm::Tracer.instance = nil
|
62
79
|
raise(exception) unless (Raygun::Apm::FatalError === exception)
|
63
80
|
end
|
64
81
|
|
65
82
|
def http_in_handler(args)
|
66
83
|
notification = ActiveSupport::Notifications::Event.new *args
|
84
|
+
if notification.payload[:exception]
|
85
|
+
return
|
86
|
+
end
|
67
87
|
req = Rack::Request.new notification.payload[:headers].env
|
68
88
|
event = http_in_event
|
69
89
|
event[:url] = req.url
|
@@ -142,6 +162,10 @@ module Raygun
|
|
142
162
|
yield
|
143
163
|
end
|
144
164
|
|
165
|
+
def Ruby_APM_request_error
|
166
|
+
yield
|
167
|
+
end
|
168
|
+
|
145
169
|
def self.finalize(tracer)
|
146
170
|
proc {tracer.process_ended}
|
147
171
|
end
|
@@ -6,6 +6,10 @@ module Raygun
|
|
6
6
|
require "raygun/apm"
|
7
7
|
require "raygun/apm/rails/middleware"
|
8
8
|
Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BLACKLIST
|
9
|
+
if Raygun::Apm::Rails.raygun4ruby?
|
10
|
+
# Remove the exception notifier because we handle it in the APM middleware now instead
|
11
|
+
app.middleware.delete Raygun::Middleware::RackExceptionInterceptor
|
12
|
+
end
|
9
13
|
app.middleware.use Raygun::Apm::Rails::Middleware
|
10
14
|
# Explictly enable instrumenting HTTP until a good control API is figured out
|
11
15
|
require "raygun/apm/hooks/net_http"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun-apm-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raygun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-03-
|
12
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: raygun-apm
|
@@ -76,6 +76,7 @@ extensions: []
|
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
78
|
- ".gitignore"
|
79
|
+
- CHANGELOG.rdoc
|
79
80
|
- Gemfile
|
80
81
|
- Gemfile.lock
|
81
82
|
- README.rdoc
|