raygun-apm-rails 1.0.14 → 1.0.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56652e1a7f4025972adeff71e48d15e0c9de9160b594c317a0542cbbb755dd68
4
- data.tar.gz: 9d5ecc225f6ff015b355847336b536a6c753b86b376f7a0122d31beaa1501103
3
+ metadata.gz: dc8275346199de493a2f17471d627e1b09cbe8ddebd5d61985e3d532eb95b440
4
+ data.tar.gz: c219ea0ec08978efda1ca62b5b483d032288d90f13b777d77ebe40e49572c90a
5
5
  SHA512:
6
- metadata.gz: 9920374e2efa710d18f2bd877ef3a9a583eda90fb3b6e5cb1f0cfc2f6cf4c84ea0876c67a0cc4714488d6658db3865e5d8716755941b15abe2cfe73cd5f92371
7
- data.tar.gz: a5da42a667bf6affb31abb3d9e9390ed1dd9bb7164b6d1d63e7dd263d218377228ff98e955617fb3eea10c25d194339cd34e01c98d2d8a458f317f866232f653
6
+ metadata.gz: 3733122e03f98a8daaff55d0bc04a8edb2ce1f0c9c9a4e74325bbec9467650250530a2dfb695be36d823dc24398f3ab468939e20d7d8040dadaaba25575a9e96
7
+ data.tar.gz: c95b95fccb7f7c60181fe56683d1862899d111fbecac33c875f94a7ccda49d73df7e90e2a8376d881dc2b0f7ef61d30f307b17e1a51299ab6c867e47b3491f43
@@ -0,0 +1,14 @@
1
+ = Changelog
2
+
3
+ == 1.0.19 (March 16, 2020)
4
+
5
+ * Improve trace emission of unhandled exceptions in a request context
6
+
7
+ == 1.0.18 (March 15, 2020)
8
+
9
+ * Ensure a better experience with raygun4ruby with only Raygun::track_exception whitelisted
10
+ * Remove the warning on a HTTP IN event with an exception payload - spams STDOUT and already confused some testers
11
+ * Ensure errors raised during request exception always result in a fully wrapped trace with a 500 status
12
+ * Wrap the exceptional HTTP IN error handler in a fake user code method too to get past the agent gate for that
13
+ * Prefer the singleton interface on the Tracer
14
+ * Blacklist HTTParty
@@ -67,7 +67,13 @@ 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
  }
72
78
  end
73
79
  end
@@ -4,7 +4,7 @@ module Raygun
4
4
  class Middleware
5
5
  def initialize(app)
6
6
  @app = app
7
- @tracer_initialized = nil
7
+ @tracer = nil
8
8
  end
9
9
 
10
10
  def call(env)
@@ -13,41 +13,27 @@ 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
-
27
- @sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
28
- sql_handler(args)
29
- end
30
-
31
- GC.stress = true if ENV['RAYGUN_STRESS_GC']
32
-
33
- # If any fatal errors on init, shutdown the tracer
34
- rescue Raygun::Apm::FatalError => e
35
- raygun_shutdown_handler(e)
36
- end
37
16
 
38
17
  def instrument(env)
39
18
  res = nil
40
- @tracer_initialized ||= initialize_tracer
41
19
  # Can be nil if we had a fatal error
20
+ @tracer ||= Raygun::Apm::Tracer.instance || init_tracer
42
21
  if @tracer
43
22
  # For the exceptional HTTP IN handler
44
23
  @request_started = @tracer.now
45
- Thread.current.thread_variable_set(:_raygun_apm_tracer, @tracer)
46
24
  @tracer.start_trace
47
25
  end
48
- res = Ruby_APM_profiler_trace{ @app.call(env) }
49
- if (status = res.first) >= 400 && status < 500 || status >= 500 && status < 600
50
- exceptional_http_in_handler(env, status)
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 { exceptional_http_in_handler(env, 500) }
33
+ end
34
+ end
35
+ if res && (status = res.first) >= 400 && status < 600
36
+ Ruby_APM_request_error { exceptional_http_in_handler(env, status) }
51
37
  end
52
38
  # Can be nil if we had a fatal error
53
39
  @tracer.end_trace if @tracer
@@ -56,6 +42,27 @@ module Raygun
56
42
  raygun_shutdown_handler(e)
57
43
  end
58
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
+
59
66
  def raygun_shutdown_handler(exception)
60
67
  warn "[Raygun APM] shutting down due to error - #{exception.message} #{exception.backtrace.join("\n")}",
61
68
  # Kill extended event subcriptions
@@ -63,13 +70,15 @@ module Raygun
63
70
  ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
64
71
  warn "[Raygun APM] notification hooks unsubscribed"
65
72
  # Let the GC clean up the sink thread through the finalizer below
66
- @tracer = nil
67
- Thread.current.thread_variable_set(:_raygun_apm_tracer, nil)
73
+ @tracer = Raygun::Apm::Tracer.instance = nil
68
74
  raise(exception) unless (Raygun::Apm::FatalError === exception)
69
75
  end
70
76
 
71
77
  def http_in_handler(args)
72
78
  notification = ActiveSupport::Notifications::Event.new *args
79
+ if notification.payload[:exception]
80
+ return
81
+ end
73
82
  req = Rack::Request.new notification.payload[:headers].env
74
83
  event = http_in_event
75
84
  event[:url] = req.url
@@ -148,6 +157,10 @@ module Raygun
148
157
  yield
149
158
  end
150
159
 
160
+ def Ruby_APM_request_error
161
+ yield
162
+ end
163
+
151
164
  def self.finalize(tracer)
152
165
  proc {tracer.process_ended}
153
166
  end
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Rails
4
- VERSION = "1.0.14"
4
+ VERSION = "1.0.19"
5
5
  end
6
6
  end
7
7
  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.14
4
+ version: 1.0.19
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-06 00:00:00.000000000 Z
12
+ date: 2020-03-17 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