plain_apm 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plain_apm/event_attributes.rb +21 -2
- data/lib/plain_apm/extensions/active_support/event.rb +77 -0
- data/lib/plain_apm/extensions/active_support/railtie.rb +19 -0
- data/lib/plain_apm/extensions/active_support.rb +2 -0
- data/lib/plain_apm/extensions/context/railtie.rb +1 -1
- data/lib/plain_apm/hooks/active_record.rb +1 -0
- data/lib/plain_apm/version.rb +1 -1
- data/lib/plain_apm.rb +2 -2
- metadata +5 -6
- data/lib/plain_apm/extensions/exceptions/active_job.rb +0 -34
- data/lib/plain_apm/extensions/thread_allocations/active_support_event.rb +0 -25
- data/lib/plain_apm/extensions/thread_allocations/railtie.rb +0 -19
- data/lib/plain_apm/extensions/thread_allocations.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72d2d8915ce85d5a10557fd615a6011840b329155bc0d8765c1a5cef05383bc3
|
4
|
+
data.tar.gz: e9473490d411042af5e1cc04d7374ebb6b8f7b5c07aebaaa0bda604ca0bfb3a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7230625a30f50a3777ba5364544979b3edf1718b752836791b4c66997bb4988ca3e8311b1a11ddbefd8de4c0c80f2bae6761532fc0a08567d7b09b67d65a2062
|
7
|
+
data.tar.gz: ff5e0376280f779a9ce2e4cd8cab148d61bf87c8280406b43a71aa409c63974d149afd727540774e564c9d383788d69b9cc533d90bd64849e86ff8f6763db536
|
@@ -31,8 +31,8 @@ module PlainApm
|
|
31
31
|
attrs[:event_source] = error_source
|
32
32
|
end
|
33
33
|
|
34
|
-
if context[:
|
35
|
-
attrs[:
|
34
|
+
if context[:controller]&.is_a?(ActionController::Base)
|
35
|
+
attrs[:controller] = context[:controller].class.name
|
36
36
|
end
|
37
37
|
|
38
38
|
if context[:job]&.is_a?(ActiveJob::Base)
|
@@ -40,6 +40,12 @@ module PlainApm
|
|
40
40
|
attrs[:queue_name] = context[:job].queue_name
|
41
41
|
end
|
42
42
|
|
43
|
+
if context[:env]
|
44
|
+
attrs[:params] = context.dig(:env, "action_dispatch.request.parameters")
|
45
|
+
attrs[:action] = context.dig(:env, "action_dispatch.request.parameters", :action)
|
46
|
+
attrs[:controller] = context.dig(:env, "action_controller.instance")&.class.name
|
47
|
+
end
|
48
|
+
|
43
49
|
# https://bugs.ruby-lang.org/issues/19197
|
44
50
|
root_cause = e
|
45
51
|
root_cause = root_cause.cause while root_cause.cause
|
@@ -73,9 +79,22 @@ module PlainApm
|
|
73
79
|
attrs[:source] = source
|
74
80
|
attrs[:name] = name
|
75
81
|
attrs[:allocations] = event.allocations
|
82
|
+
attrs[:thread_cpu_time] = event.cpu_time
|
76
83
|
attrs[:event_time] = event.time
|
77
84
|
attrs[:duration] = event.duration
|
78
85
|
|
86
|
+
if event.respond_to?(:gc_time)
|
87
|
+
attrs[:gc_time] = event.gc_time
|
88
|
+
end
|
89
|
+
|
90
|
+
if event.respond_to?(:gc_major_count)
|
91
|
+
attrs[:gc_major_count] = event.gc_major_count
|
92
|
+
end
|
93
|
+
|
94
|
+
if event.respond_to?(:gc_minor_count)
|
95
|
+
attrs[:gc_minor_count] = event.gc_minor_count
|
96
|
+
end
|
97
|
+
|
79
98
|
if event.respond_to?(:thread_allocations)
|
80
99
|
attrs[:thread_allocations] = event.thread_allocations
|
81
100
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module PlainApm
|
2
|
+
module Extensions
|
3
|
+
module ActiveSupport
|
4
|
+
module Event
|
5
|
+
def start!
|
6
|
+
super
|
7
|
+
@thread_allocation_count_start = now_thread_allocations
|
8
|
+
@gc_time_start = now_gc_time
|
9
|
+
@gc_major_count_start = now_gc_major_count
|
10
|
+
@gc_minor_count_start = now_gc_minor_count
|
11
|
+
end
|
12
|
+
|
13
|
+
def finish!
|
14
|
+
super
|
15
|
+
@thread_allocation_count_finish = now_thread_allocations
|
16
|
+
@gc_time_finish = now_gc_time
|
17
|
+
@gc_major_count_finish = now_gc_major_count
|
18
|
+
@gc_minor_count_finish = now_gc_minor_count
|
19
|
+
end
|
20
|
+
|
21
|
+
def thread_allocations
|
22
|
+
@thread_allocation_count_finish - @thread_allocation_count_start
|
23
|
+
end
|
24
|
+
|
25
|
+
def gc_time
|
26
|
+
@gc_time_finish - @gc_time_start
|
27
|
+
end
|
28
|
+
|
29
|
+
def gc_major_count
|
30
|
+
@gc_major_count_finish - @gc_major_count_start
|
31
|
+
end
|
32
|
+
|
33
|
+
def gc_minor_count
|
34
|
+
@gc_minor_count_finish - @gc_minor_count_start
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# Per thread GC counter
|
40
|
+
def now_thread_allocations
|
41
|
+
PlainApm::ObjectTracing.total_thread_allocated_objects
|
42
|
+
end
|
43
|
+
|
44
|
+
if GC.stat.key?(:major_gc_count)
|
45
|
+
def now_gc_major_count
|
46
|
+
GC.stat(:major_gc_count)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
def now_gc_major_count
|
50
|
+
0
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if GC.stat.key?(:minor_gc_count)
|
55
|
+
def now_gc_minor_count
|
56
|
+
GC.stat(:minor_gc_count)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
def now_gc_minor_count
|
60
|
+
0
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Time in ms spent in GC
|
65
|
+
if GC.stat.key?(:time)
|
66
|
+
def now_gc_time
|
67
|
+
GC.stat(:time)
|
68
|
+
end
|
69
|
+
else
|
70
|
+
def now_gc_time
|
71
|
+
0
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlainApm
|
4
|
+
module Extensions
|
5
|
+
module ActiveSupport
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
initializer(:plain_apm_thread_allocations, after: :plain_apm_agent_start) do
|
8
|
+
next if !PlainApm.agent.enabled?
|
9
|
+
|
10
|
+
require "object_tracing"
|
11
|
+
|
12
|
+
::ActiveSupport::Notifications::Event.prepend(
|
13
|
+
PlainApm::Extensions::ActiveSupport::Event
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -14,7 +14,7 @@ module PlainApm
|
|
14
14
|
initializer(:plain_apm_thread_context, after: :plain_apm_agent_start) do |app|
|
15
15
|
next if !PlainApm.agent.enabled?
|
16
16
|
|
17
|
-
ActiveSupport.on_load(:active_job, run_once: true) do |klass|
|
17
|
+
::ActiveSupport.on_load(:active_job, run_once: true) do |klass|
|
18
18
|
klass.prepend(PlainApm::Extensions::Context::ActiveJob)
|
19
19
|
end
|
20
20
|
|
data/lib/plain_apm/version.rb
CHANGED
data/lib/plain_apm.rb
CHANGED
@@ -24,8 +24,8 @@ require_relative "plain_apm/extensions/context"
|
|
24
24
|
# Rack exceptions. Activate the middleware if in Rails.
|
25
25
|
require_relative "plain_apm/extensions/exceptions"
|
26
26
|
|
27
|
-
#
|
28
|
-
require_relative "plain_apm/extensions/
|
27
|
+
# Extra stats in ASN events
|
28
|
+
require_relative "plain_apm/extensions/active_support"
|
29
29
|
|
30
30
|
# Rails instrumentation. The hooks won't install unless
|
31
31
|
# ActiveSupport::Notifications is loaded.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plain_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PlainAPM Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -101,6 +101,9 @@ files:
|
|
101
101
|
- lib/plain_apm/config.rb
|
102
102
|
- lib/plain_apm/deploy_tracking.rb
|
103
103
|
- lib/plain_apm/event_attributes.rb
|
104
|
+
- lib/plain_apm/extensions/active_support.rb
|
105
|
+
- lib/plain_apm/extensions/active_support/event.rb
|
106
|
+
- lib/plain_apm/extensions/active_support/railtie.rb
|
104
107
|
- lib/plain_apm/extensions/context.rb
|
105
108
|
- lib/plain_apm/extensions/context/LICENSE.txt
|
106
109
|
- lib/plain_apm/extensions/context/active_job.rb
|
@@ -108,12 +111,8 @@ files:
|
|
108
111
|
- lib/plain_apm/extensions/context/rack.rb
|
109
112
|
- lib/plain_apm/extensions/context/railtie.rb
|
110
113
|
- lib/plain_apm/extensions/exceptions.rb
|
111
|
-
- lib/plain_apm/extensions/exceptions/active_job.rb
|
112
114
|
- lib/plain_apm/extensions/exceptions/rack.rb
|
113
115
|
- lib/plain_apm/extensions/exceptions/railtie.rb
|
114
|
-
- lib/plain_apm/extensions/thread_allocations.rb
|
115
|
-
- lib/plain_apm/extensions/thread_allocations/active_support_event.rb
|
116
|
-
- lib/plain_apm/extensions/thread_allocations/railtie.rb
|
117
116
|
- lib/plain_apm/helpers.rb
|
118
117
|
- lib/plain_apm/hooks/action_mailer.rb
|
119
118
|
- lib/plain_apm/hooks/action_pack.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PlainApm
|
4
|
-
module Extensions
|
5
|
-
module TraceId
|
6
|
-
module ActiveJob
|
7
|
-
attr_accessor :trace_id
|
8
|
-
|
9
|
-
def initialize(*arguments)
|
10
|
-
super(*arguments)
|
11
|
-
|
12
|
-
# Either from request headers / a previous job, or a new trace.
|
13
|
-
@trace_id = PlainApm::Extensions::TraceId.current || SecureRandom.uuid
|
14
|
-
end
|
15
|
-
|
16
|
-
def serialize
|
17
|
-
super.update("trace_id" => trace_id)
|
18
|
-
end
|
19
|
-
|
20
|
-
def deserialize(job)
|
21
|
-
PlainApm::Extensions::TraceId.current = job["trace_id"]
|
22
|
-
|
23
|
-
super(job)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
##
|
28
|
-
# Allow tracing request ID through jobs
|
29
|
-
ActiveSupport.on_load(:active_job, run_once: true) do |klass|
|
30
|
-
klass.prepend(ActiveJob)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module PlainApm
|
2
|
-
module Extensions
|
3
|
-
module ThreadAllocations
|
4
|
-
module ActiveSupportEvent
|
5
|
-
def start!
|
6
|
-
super
|
7
|
-
@thread_allocation_count_start = now_thread_allocations
|
8
|
-
end
|
9
|
-
|
10
|
-
def finish!
|
11
|
-
super
|
12
|
-
@thread_allocation_count_finish = now_thread_allocations
|
13
|
-
end
|
14
|
-
|
15
|
-
def thread_allocations
|
16
|
-
@thread_allocation_count_finish - @thread_allocation_count_start
|
17
|
-
end
|
18
|
-
|
19
|
-
def now_thread_allocations
|
20
|
-
PlainApm::ObjectTracing.total_thread_allocated_objects
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PlainApm
|
4
|
-
module Extensions
|
5
|
-
module ThreadAllocations
|
6
|
-
class Railtie < Rails::Railtie
|
7
|
-
initializer(:plain_apm_thread_allocationss, after: :plain_apm_agent_start) do
|
8
|
-
next if !PlainApm.agent.enabled?
|
9
|
-
|
10
|
-
require "object_tracing"
|
11
|
-
|
12
|
-
ActiveSupport::Notifications::Event.prepend(
|
13
|
-
PlainApm::Extensions::ThreadAllocations::ActiveSupportEvent
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|