raygun-apm-sidekiq 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95e0d6120faf33879735ee5fdf79c9f1c02811b1dc37302408597c6d2858d132
4
- data.tar.gz: 676ffb5e73117d303c434f0af95cb14bac52cb1472701a3832db2d7f617d372c
3
+ metadata.gz: 5d47af0b57af919bbbcfd30f03f6170f48544ea379f3a112504b77b04a21f728
4
+ data.tar.gz: 768d91496b52936ecab2582091943b997768922ce196ebba17c33ffbc1c5edb0
5
5
  SHA512:
6
- metadata.gz: 62d74bf1bb52950794ceb9d06501fd7567903c1e8f112ae371c53a712d19b7fad51a9bce7973b32109c912a87a76734a87914a762ad8bdcab88cd77fa5b91557
7
- data.tar.gz: 48bf45bbb2225efb071959173cb8344b08acfae4f0d3d1474ca0cdc7770a8089d8b791859b18f6f009aaa4182b26205f2b968bd8a278e35ae444484d15c4383f
6
+ metadata.gz: 46eddc75761d8f7acf5ce5089ac33c340aaac03b915804237bba61ae19e594c0c56cca68bc504304ddcaa2005f900232a09b6d4b61b8fc150af7119ab0ed77f2
7
+ data.tar.gz: e0a2196341004b863bc00966e86ea7bd8b7c52cdab655c1c9002277f41f896e12e5bd41ba85418bcd4adadf5ef3e64c5b95630a402f5834409ffe55aa0b2904b
@@ -3,28 +3,10 @@ module Raygun
3
3
  module Sidekiq
4
4
  class Middleware
5
5
  def initialize
6
- @tracer_initialized = nil
7
- end
8
-
9
- def initialize_tracer
10
- @tracer = Raygun::Apm::Tracer.new
11
- @tracer.udp_sink!
12
- @tracer.process_started
13
- ObjectSpace.define_finalizer(self, self.class.finalize(@tracer))
14
-
15
- @sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
16
- sql_handler(args)
17
- end
18
-
19
- GC.stress = true if ENV['RAYGUN_STRESS_GC']
20
-
21
- # If any fatal errors on init, shutdown the tracer
22
- rescue Raygun::Apm::FatalError => e
23
- raygun_shutdown_handler(e)
6
+ @tracer = self.class.init_tracer
24
7
  end
25
8
 
26
9
  def call(worker_instance, msg, queue)
27
- @tracer_initialized ||= initialize_tracer
28
10
  # Can be nil if we had a fatal error
29
11
  if @tracer
30
12
  started = @tracer.now
@@ -39,14 +21,34 @@ module Raygun
39
21
  end
40
22
  # Can be nil if we had a fatal error
41
23
  if @tracer
42
- fake_http_in_handler(started, worker_instance, msg, queue, exception)
24
+ self.class.fake_http_in_handler(started, worker_instance, msg, queue, exception)
43
25
  @tracer.end_trace
44
26
  end
45
27
  rescue Raygun::Apm::FatalError => e
46
- raygun_shutdown_handler(e)
28
+ self.class.raygun_shutdown_handler(e)
47
29
  end
30
+
31
+ private
32
+
33
+ def self.init_tracer
34
+ return @tracer if @tracer
35
+ @tracer = Raygun::Apm::Tracer.new
36
+ @tracer.udp_sink!
37
+ @tracer.process_started
38
+ ObjectSpace.define_finalizer(self, self.finalize(@tracer))
48
39
 
49
- def raygun_shutdown_handler(exception)
40
+ @sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
41
+ sql_handler(args)
42
+ end
43
+
44
+ GC.stress = true if ENV['RAYGUN_STRESS_GC']
45
+ @tracer
46
+ # If any fatal errors on init, shutdown the tracer
47
+ rescue Raygun::Apm::FatalError => e
48
+ raygun_shutdown_handler(e)
49
+ end
50
+
51
+ def self.raygun_shutdown_handler(exception)
50
52
  warn "Raygun APM shutting down due to error - %s", exception.message
51
53
  # Kill extended event subcriptions
52
54
  ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
@@ -57,7 +59,7 @@ module Raygun
57
59
  raise(exception) unless (Raygun::Apm::FatalError === exception)
58
60
  end
59
61
 
60
- def fake_http_in_handler(started, worker_instance, msg, queue, exception)
62
+ def self.fake_http_in_handler(started, worker_instance, msg, queue, exception)
61
63
  ended = @tracer.now
62
64
  event = http_in_event
63
65
  event[:url] = "sidekiq://#{queue}/#{msg["class"]}?#{msg["jid"]}"
@@ -72,7 +74,7 @@ module Raygun
72
74
  raygun_shutdown_handler(e)
73
75
  end
74
76
 
75
- def http_in_event
77
+ def self.http_in_event
76
78
  @http_in_event ||= begin
77
79
  event = Raygun::Apm::Event::HttpIn.new
78
80
  event[:pid] = Process.pid
@@ -81,7 +83,7 @@ module Raygun
81
83
  end
82
84
  end
83
85
 
84
- def sql_handler(args)
86
+ def self.sql_handler(args)
85
87
  notification = ActiveSupport::Notifications::Event.new *args
86
88
  connection = if notification.payload[:connection]
87
89
  notification.payload[:connection]
@@ -108,7 +110,7 @@ module Raygun
108
110
  raygun_shutdown_handler(e)
109
111
  end
110
112
 
111
- def sql_event
113
+ def self.sql_event
112
114
  @sql_event ||= begin
113
115
  event = Raygun::Apm::Event::Sql.new
114
116
  event[:pid] = Process.pid
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Sidekiq
4
- VERSION = "1.0.9"
4
+ VERSION = "1.0.10"
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-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
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-03 00:00:00.000000000 Z
12
+ date: 2020-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: raygun-apm