raygun-apm-rails 1.0.13 → 1.0.18
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 +10 -0
- data/lib/raygun/apm/rails.rb +10 -0
- data/lib/raygun/apm/rails/middleware.rb +59 -28
- data/lib/raygun/apm/rails/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715626f8f9976fa6af04de7e06b2977e1dc261f48e50e27b01edd4772af08be9
|
4
|
+
data.tar.gz: a25c402d9238165a0664047bfe15a5074e3c4c7088ccb28af2fddb5cdacc09b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d86b7b853a306a61b9993f417abce9a861b2c41ac2a68129e003b2e4d9f5e7cd90d1dfb4027bd1ceee5ed9cc2df98ef652e9abf98045cd13169cc95061dcb28
|
7
|
+
data.tar.gz: 610ff0610f8b9176fa747b97c9bf6e6db312c8fc9df06e4e87cd55e94c16939a9e6c11d4889a3c0561984e4dd90ae565b48e98a636a9da9fcef912d06565e55e
|
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
== 1.0.18 (March 15, 2020)
|
4
|
+
|
5
|
+
* Ensure a better experience with raygun4ruby with only Raygun::track_exception whitelisted
|
6
|
+
* Remove the warning on a HTTP IN event with an exception payload - spams STDOUT and already confused some testers
|
7
|
+
* Ensure errors raised during request exception always result in a fully wrapped trace with a 500 status
|
8
|
+
* Wrap the exceptional HTTP IN error handler in a fake user code method too to get past the agent gate for that
|
9
|
+
* Prefer the singleton interface on the Tracer
|
10
|
+
* Blacklist HTTParty
|
data/lib/raygun/apm/rails.rb
CHANGED
@@ -63,7 +63,17 @@ module Raygun
|
|
63
63
|
Zeitwerk
|
64
64
|
SassC
|
65
65
|
Webpacker
|
66
|
+
DidYouMean
|
67
|
+
Nokogiri
|
68
|
+
Loofah
|
69
|
+
WebConsole
|
70
|
+
HTTParty
|
71
|
+
Raygun::Breadcrumbs
|
72
|
+
Raygun::Configuration
|
73
|
+
Raygun::config
|
66
74
|
+Raygun::Apm::Rails::Middleware::Ruby_APM_profiler_trace
|
75
|
+
+Raygun::Apm::Rails::Middleware::Ruby_APM_request_error
|
76
|
+
+Raygun::track_exception
|
67
77
|
}
|
68
78
|
end
|
69
79
|
end
|
@@ -4,7 +4,7 @@ module Raygun
|
|
4
4
|
class Middleware
|
5
5
|
def initialize(app)
|
6
6
|
@app = app
|
7
|
-
@
|
7
|
+
@tracer = nil
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
@@ -13,36 +13,28 @@ module Raygun
|
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
|
-
|
17
|
-
def initialize_tracer
|
18
|
-
@tracer = Raygun::Apm::Tracer.new
|
19
|
-
@tracer.udp_sink!
|
20
|
-
@tracer.process_started
|
21
|
-
ObjectSpace.define_finalizer(self, self.class.finalize(@tracer))
|
22
|
-
|
23
|
-
@http_in_subscriber = ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
24
|
-
http_in_handler(args)
|
25
|
-
end
|
26
|
-
@sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
27
|
-
sql_handler(args)
|
28
|
-
end
|
29
|
-
|
30
|
-
GC.stress = true if ENV['RAYGUN_STRESS_GC']
|
31
|
-
|
32
|
-
# If any fatal errors on init, shutdown the tracer
|
33
|
-
rescue Raygun::Apm::FatalError => e
|
34
|
-
raygun_shutdown_handler(e)
|
35
|
-
end
|
36
16
|
|
37
17
|
def instrument(env)
|
38
18
|
res = nil
|
39
|
-
@tracer_initialized ||= initialize_tracer
|
40
19
|
# Can be nil if we had a fatal error
|
20
|
+
@tracer ||= Raygun::Apm::Tracer.instance || init_tracer
|
41
21
|
if @tracer
|
42
|
-
|
22
|
+
# For the exceptional HTTP IN handler
|
23
|
+
@request_started = @tracer.now
|
43
24
|
@tracer.start_trace
|
44
25
|
end
|
45
|
-
|
26
|
+
exception = nil
|
27
|
+
res = nil
|
28
|
+
Ruby_APM_profiler_trace do
|
29
|
+
begin
|
30
|
+
res = @app.call(env)
|
31
|
+
rescue
|
32
|
+
exceptional_http_in_handler(env, 500)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
if (status = res.first) >= 400 && status < 600
|
36
|
+
Ruby_APM_request_error { exceptional_http_in_handler(env, status) }
|
37
|
+
end
|
46
38
|
# Can be nil if we had a fatal error
|
47
39
|
@tracer.end_trace if @tracer
|
48
40
|
res
|
@@ -50,22 +42,41 @@ module Raygun
|
|
50
42
|
raygun_shutdown_handler(e)
|
51
43
|
end
|
52
44
|
|
45
|
+
def init_tracer
|
46
|
+
tracer = Raygun::Apm::Tracer.new
|
47
|
+
tracer.udp_sink!
|
48
|
+
tracer.process_started
|
49
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(tracer))
|
50
|
+
|
51
|
+
@http_in_subscriber = ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
52
|
+
http_in_handler(args)
|
53
|
+
end
|
54
|
+
|
55
|
+
@sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
56
|
+
sql_handler(args)
|
57
|
+
end
|
58
|
+
|
59
|
+
GC.stress = true if ENV['RAYGUN_STRESS_GC']
|
60
|
+
Raygun::Apm::Tracer.instance = tracer
|
61
|
+
# If any fatal errors on init, shutdown the tracer
|
62
|
+
rescue Raygun::Apm::FatalError => e
|
63
|
+
raygun_shutdown_handler(e)
|
64
|
+
end
|
65
|
+
|
53
66
|
def raygun_shutdown_handler(exception)
|
54
|
-
warn "[Raygun APM] shutting down due to error - #{exception.message}",
|
67
|
+
warn "[Raygun APM] shutting down due to error - #{exception.message} #{exception.backtrace.join("\n")}",
|
55
68
|
# Kill extended event subcriptions
|
56
69
|
ActiveSupport::Notifications.unsubscribe(@http_in_subscriber)
|
57
70
|
ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
|
58
71
|
warn "[Raygun APM] notification hooks unsubscribed"
|
59
72
|
# 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)
|
73
|
+
@tracer = Raygun::Apm::Tracer.instance = nil
|
62
74
|
raise(exception) unless (Raygun::Apm::FatalError === exception)
|
63
75
|
end
|
64
76
|
|
65
77
|
def http_in_handler(args)
|
66
78
|
notification = ActiveSupport::Notifications::Event.new *args
|
67
79
|
if notification.payload[:exception]
|
68
|
-
warn "[Raygun APM] exception in HTTP IN event: #{notification.payload[:exception]}"
|
69
80
|
return
|
70
81
|
end
|
71
82
|
req = Rack::Request.new notification.payload[:headers].env
|
@@ -83,6 +94,22 @@ module Raygun
|
|
83
94
|
raygun_shutdown_handler(e)
|
84
95
|
end
|
85
96
|
|
97
|
+
# For middleware chain halts that does not trigger 'process_action.action_controller'
|
98
|
+
def exceptional_http_in_handler(env, status)
|
99
|
+
req = Rack::Request.new env
|
100
|
+
event = http_in_event
|
101
|
+
event[:url] = req.url
|
102
|
+
event[:verb] = req.request_method
|
103
|
+
event[:status] = status
|
104
|
+
event[:duration] = @tracer.now - @request_started
|
105
|
+
event[:timestamp] = @tracer.now
|
106
|
+
event[:tid] = @tracer.get_thread_id(Thread.current)
|
107
|
+
@tracer.emit(event)
|
108
|
+
rescue => e
|
109
|
+
warn "[Raygun APM] error reporting exceptional HTTP IN event"
|
110
|
+
raygun_shutdown_handler(e)
|
111
|
+
end
|
112
|
+
|
86
113
|
def http_in_event
|
87
114
|
@http_in_event ||= begin
|
88
115
|
event = Raygun::Apm::Event::HttpIn.new
|
@@ -130,6 +157,10 @@ module Raygun
|
|
130
157
|
yield
|
131
158
|
end
|
132
159
|
|
160
|
+
def Ruby_APM_request_error
|
161
|
+
yield
|
162
|
+
end
|
163
|
+
|
133
164
|
def self.finalize(tracer)
|
134
165
|
proc {tracer.process_ended}
|
135
166
|
end
|
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.18
|
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-15 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
|
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
106
|
- !ruby/object:Gem::Version
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
|
-
rubygems_version: 3.0.
|
109
|
+
rubygems_version: 3.0.6
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Raygun application performance monitoring for Rails
|