raygun-apm-rails 1.0.10 → 1.0.15

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: 477de1c6c1324d9e29972fea02bf4b237f2c21d2709a1db75957f5c1a6063dde
4
- data.tar.gz: 6f8931ecc7176d8e59edb608dc980f720dca9a56e3b353007b2156894943db7d
3
+ metadata.gz: 79c1cf537ee9e8f781c49e3c2cc6cc74b8b38225e50e34bca773cae3cfdbc6b1
4
+ data.tar.gz: 5bd799bfa20772be1aa736220be6bb9efbfdc0aeb07d6b5c84a24b9d3bda0ac5
5
5
  SHA512:
6
- metadata.gz: 78c34e90d2b77e0f5f9d905c28f862c44207b79f3603b31df1d10737514114ac1de7143ffcff17f54e0ef7bbcadbf29d2598c36adfe06c0ef49df2fa8460001f
7
- data.tar.gz: ddad0b9826e634c8f6d2dd041ee812f7eb3aa2879274cb91ab69075006dbf0799f07443a1a7c0d6465bcb05f397bb2682a1a482bb228b6ae776d943a9729cf61
6
+ metadata.gz: a9770fa4db4c1b7d7bdb1a3a404a84d57587f61fe68466cff9c11440396ce59d21a05fe26184b2e4ed5b229eaf6d50af6b801f72353a746d2e044624ea58686d
7
+ data.tar.gz: a2282067547e6e0d0928f2c9269d97331ba98224d6f6078ded343a4e953ebc874f74aa9e5374fde64a4294958e5e4f16d939405f4fe4c7b60a5032fb8cf72330
@@ -60,6 +60,13 @@ module Raygun
60
60
  ConnectionPool
61
61
  CoffeeScript
62
62
  ApplicationRecord
63
+ Zeitwerk
64
+ SassC
65
+ Webpacker
66
+ DidYouMean
67
+ Nokogiri
68
+ Loofah
69
+ WebConsole
63
70
  +Raygun::Apm::Rails::Middleware::Ruby_APM_profiler_trace
64
71
  }
65
72
  end
@@ -4,17 +4,6 @@ module Raygun
4
4
  class Middleware
5
5
  def initialize(app)
6
6
  @app = app
7
- @tracer_initialized = nil
8
- end
9
-
10
- def call(env)
11
- @status, @headers, @response = instrument(env)
12
- [@status, @headers, @response]
13
- end
14
-
15
- private
16
-
17
- def initialize_tracer
18
7
  @tracer = Raygun::Apm::Tracer.new
19
8
  @tracer.udp_sink!
20
9
  @tracer.process_started
@@ -23,26 +12,37 @@ module Raygun
23
12
  @http_in_subscriber = ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
24
13
  http_in_handler(args)
25
14
  end
15
+
26
16
  @sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
27
17
  sql_handler(args)
28
18
  end
29
19
 
30
20
  GC.stress = true if ENV['RAYGUN_STRESS_GC']
31
-
32
21
  # If any fatal errors on init, shutdown the tracer
33
22
  rescue Raygun::Apm::FatalError => e
34
23
  raygun_shutdown_handler(e)
35
24
  end
25
+
26
+ def call(env)
27
+ @status, @headers, @response = instrument(env)
28
+ [@status, @headers, @response]
29
+ end
30
+
31
+ private
36
32
 
37
33
  def instrument(env)
38
34
  res = nil
39
- @tracer_initialized ||= initialize_tracer
40
35
  # Can be nil if we had a fatal error
41
36
  if @tracer
37
+ # For the exceptional HTTP IN handler
38
+ @request_started = @tracer.now
42
39
  Thread.current.thread_variable_set(:_raygun_apm_tracer, @tracer)
43
40
  @tracer.start_trace
44
41
  end
45
42
  res = Ruby_APM_profiler_trace{ @app.call(env) }
43
+ if (status = res.first) >= 400 && status < 600
44
+ exceptional_http_in_handler(env, status)
45
+ end
46
46
  # Can be nil if we had a fatal error
47
47
  @tracer.end_trace if @tracer
48
48
  res
@@ -51,13 +51,11 @@ module Raygun
51
51
  end
52
52
 
53
53
  def raygun_shutdown_handler(exception)
54
- warn "[Raygun APM] shutting down due to error - #{exception.message}",
54
+ warn "[Raygun APM] shutting down due to error - #{exception.message} #{exception.backtrace.join("\n")}",
55
55
  # Kill extended event subcriptions
56
56
  ActiveSupport::Notifications.unsubscribe(@http_in_subscriber)
57
57
  ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
58
58
  warn "[Raygun APM] notification hooks unsubscribed"
59
- # Shutdown the tracepoints if enabled to reduce any overhead and stall emission
60
- @tracer.stop_tracepoints
61
59
  # Let the GC clean up the sink thread through the finalizer below
62
60
  @tracer = nil
63
61
  Thread.current.thread_variable_set(:_raygun_apm_tracer, nil)
@@ -66,10 +64,6 @@ module Raygun
66
64
 
67
65
  def http_in_handler(args)
68
66
  notification = ActiveSupport::Notifications::Event.new *args
69
- if notification.payload[:exception]
70
- warn "[Raygun APM] exception in HTTP IN event: #{notification.payload[:exception]}"
71
- return
72
- end
73
67
  req = Rack::Request.new notification.payload[:headers].env
74
68
  event = http_in_event
75
69
  event[:url] = req.url
@@ -85,6 +79,22 @@ module Raygun
85
79
  raygun_shutdown_handler(e)
86
80
  end
87
81
 
82
+ # For middleware chain halts that does not trigger 'process_action.action_controller'
83
+ def exceptional_http_in_handler(env, status)
84
+ req = Rack::Request.new env
85
+ event = http_in_event
86
+ event[:url] = req.url
87
+ event[:verb] = req.request_method
88
+ event[:status] = status
89
+ event[:duration] = @tracer.now - @request_started
90
+ event[:timestamp] = @tracer.now
91
+ event[:tid] = @tracer.get_thread_id(Thread.current)
92
+ @tracer.emit(event)
93
+ rescue => e
94
+ warn "[Raygun APM] error reporting exceptional HTTP IN event"
95
+ raygun_shutdown_handler(e)
96
+ end
97
+
88
98
  def http_in_event
89
99
  @http_in_event ||= begin
90
100
  event = Raygun::Apm::Event::HttpIn.new
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Rails
4
- VERSION = "1.0.10"
4
+ VERSION = "1.0.15"
5
5
  end
6
6
  end
7
7
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency "raygun-apm", "~> 1.0.8"
23
+ spec.add_dependency "raygun-apm", "~> 1.0.15"
24
24
  spec.add_development_dependency "bundler", "~> 1.17"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "minitest", "~> 5.0"
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.10
4
+ version: 1.0.15
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-02 00:00:00.000000000 Z
12
+ date: 2020-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: raygun-apm
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.8
20
+ version: 1.0.15
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.8
27
+ version: 1.0.15
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement