raygun-apm-sidekiq 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +6 -0
- data/lib/raygun/apm/sidekiq/middleware.rb +19 -23
- data/lib/raygun/apm/sidekiq/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: ada58e6aa2ff6b48c268217c38693cac278aa306f682eb2dc69f73edb53b3b2e
|
4
|
+
data.tar.gz: 379565ec5a6a69f2f1f895bdbe60c7506a6eccd7cc913a773591021bb8a44003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bba188aa02c29dea66a6e8936da18a744328fa583e848aebb7fa37a524a0d79ba726b675106663c707252bf4b2179a288e7ec3f3149ee2426aeee0b65f8b0906
|
7
|
+
data.tar.gz: e9302fe170f3eb1b848303908399b5e9b507dcd6234cda89157eb0ccd0594ec95fdc7551385cbbb676050c0c32247d50595c781a39f31a7f514a9d0e9bb2877d
|
data/CHANGELOG.rdoc
ADDED
@@ -3,27 +3,24 @@ module Raygun
|
|
3
3
|
module Sidekiq
|
4
4
|
class Middleware
|
5
5
|
def initialize
|
6
|
-
@tracer = self.class.init_tracer
|
6
|
+
@tracer = Raygun::Apm::Tracer.instance || self.class.init_tracer
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(worker_instance, msg, queue)
|
10
10
|
# Can be nil if we had a fatal error
|
11
11
|
if @tracer
|
12
12
|
started = @tracer.now
|
13
|
-
Thread.current.thread_variable_set(:_raygun_apm_tracer, @tracer)
|
14
13
|
@tracer.start_trace
|
15
14
|
end
|
16
15
|
exception = nil
|
17
16
|
Ruby_APM_profiler_trace do
|
18
17
|
yield
|
18
|
+
self.class.fake_http_in_handler(@tracer, started, worker_instance, msg, queue, nil) if @tracer
|
19
19
|
rescue => e
|
20
|
-
exception
|
20
|
+
self.class.fake_http_in_handler(@tracer, started, worker_instance, msg, queue, exception) if @tracer
|
21
21
|
end
|
22
22
|
# Can be nil if we had a fatal error
|
23
|
-
if @tracer
|
24
|
-
self.class.fake_http_in_handler(started, worker_instance, msg, queue, exception)
|
25
|
-
@tracer.end_trace
|
26
|
-
end
|
23
|
+
@tracer.end_trace if @tracer
|
27
24
|
rescue Raygun::Apm::FatalError => e
|
28
25
|
self.class.raygun_shutdown_handler(e)
|
29
26
|
end
|
@@ -31,18 +28,17 @@ module Raygun
|
|
31
28
|
private
|
32
29
|
|
33
30
|
def self.init_tracer
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ObjectSpace.define_finalizer(self, self.finalize(@tracer))
|
31
|
+
tracer = Raygun::Apm::Tracer.new
|
32
|
+
tracer.udp_sink!
|
33
|
+
tracer.process_started
|
34
|
+
ObjectSpace.define_finalizer(self, self.finalize(tracer))
|
39
35
|
|
40
36
|
@sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
41
|
-
sql_handler(args)
|
37
|
+
sql_handler(tracer, args)
|
42
38
|
end
|
43
39
|
|
44
40
|
GC.stress = true if ENV['RAYGUN_STRESS_GC']
|
45
|
-
|
41
|
+
Raygun::Apm::Tracer.instance = tracer
|
46
42
|
# If any fatal errors on init, shutdown the tracer
|
47
43
|
rescue Raygun::Apm::FatalError => e
|
48
44
|
raygun_shutdown_handler(e)
|
@@ -55,19 +51,19 @@ module Raygun
|
|
55
51
|
warn "[Raygun APM] notification hooks unsubscribed"
|
56
52
|
# Let the GC clean up the sink thread through the finalizer below
|
57
53
|
@tracer = nil
|
58
|
-
|
54
|
+
Raygun::Apm::Tracer.instance = nil
|
59
55
|
raise(exception) unless (Raygun::Apm::FatalError === exception)
|
60
56
|
end
|
61
57
|
|
62
|
-
def self.fake_http_in_handler(started, worker_instance, msg, queue, exception)
|
63
|
-
ended =
|
58
|
+
def self.fake_http_in_handler(tracer, started, worker_instance, msg, queue, exception)
|
59
|
+
ended = tracer.now
|
64
60
|
event = http_in_event
|
65
61
|
event[:url] = "sidekiq://#{queue}/#{msg["class"]}?#{msg["jid"]}"
|
66
62
|
event[:status] = exception ? 500 : 200
|
67
63
|
event[:duration] = ended - started
|
68
|
-
event[:timestamp] =
|
69
|
-
event[:tid] =
|
70
|
-
|
64
|
+
event[:timestamp] = tracer.now
|
65
|
+
event[:tid] = tracer.get_thread_id(Thread.current)
|
66
|
+
tracer.emit(event)
|
71
67
|
raise(exception) if exception
|
72
68
|
rescue => e
|
73
69
|
warn "[Raygun APM] error reporting HTTP IN event"
|
@@ -83,7 +79,7 @@ module Raygun
|
|
83
79
|
end
|
84
80
|
end
|
85
81
|
|
86
|
-
def self.sql_handler(args)
|
82
|
+
def self.sql_handler(tracer, args)
|
87
83
|
notification = ActiveSupport::Notifications::Event.new *args
|
88
84
|
connection = if notification.payload[:connection]
|
89
85
|
notification.payload[:connection]
|
@@ -103,8 +99,8 @@ module Raygun
|
|
103
99
|
# XXX constant milliseconds to microseconds
|
104
100
|
event[:duration] = notification.duration * 1000
|
105
101
|
event[:timestamp] = notification.time.to_f * 1000000
|
106
|
-
event[:tid] =
|
107
|
-
|
102
|
+
event[:tid] = tracer.get_thread_id(Thread.current)
|
103
|
+
tracer.emit(event)
|
108
104
|
rescue => e
|
109
105
|
warn "[Raygun APM] error reporting SQL event"
|
110
106
|
raygun_shutdown_handler(e)
|
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.
|
4
|
+
version: 1.0.11
|
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
|
@@ -75,6 +75,7 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- CHANGELOG.rdoc
|
78
79
|
- Gemfile
|
79
80
|
- Gemfile.lock
|
80
81
|
- README.rdoc
|