plain_apm 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -0
- data/ext/object_tracing/extconf.rb +6 -0
- data/ext/object_tracing/object_tracing.c +25 -0
- data/lib/plain_apm/extensions/thread_allocations.rb +35 -0
- data/lib/plain_apm/hooks/action_mailer.rb +1 -0
- data/lib/plain_apm/hooks/action_pack.rb +1 -0
- data/lib/plain_apm/hooks/action_view.rb +2 -1
- data/lib/plain_apm/hooks/active_job.rb +1 -0
- data/lib/plain_apm/hooks/active_record.rb +2 -1
- data/lib/plain_apm/hooks/manual.rb +1 -0
- data/lib/plain_apm/version.rb +1 -1
- data/lib/plain_apm.rb +3 -0
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 279338102fbc7e827cc33a707aeafee949af9668fca997dbaabaa3de3555c3b6
|
4
|
+
data.tar.gz: 54c65a431b2ed06d58444c1a8a178f5f80105f3d7383586c1ffec184d46c1e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f27b3d576b02f43a190a2c98054c06ed85f562801ed71e47b4e0969b636a7d7c1197dec61203b0c7ea3bae727272069224085ef07258ae216101df135831f89
|
7
|
+
data.tar.gz: bf82ba5a3e6276bca9b763032b93a4ecc272eb6d112cad0c760b95952be580298540280827fc192b7e945e737be8b019fd2f986218bbcddd08720addd5e5e983
|
data/Rakefile
CHANGED
@@ -4,6 +4,7 @@ require "bundler/gem_tasks"
|
|
4
4
|
require "appraisal"
|
5
5
|
require "standard/rake"
|
6
6
|
require "rake/testtask"
|
7
|
+
require "rake/extensiontask"
|
7
8
|
|
8
9
|
Rake::TestTask.new(:test) do |t|
|
9
10
|
t.libs << "test"
|
@@ -11,6 +12,8 @@ Rake::TestTask.new(:test) do |t|
|
|
11
12
|
t.test_files = FileList["test/**/*_test.rb"]
|
12
13
|
end
|
13
14
|
|
15
|
+
Rake::ExtensionTask.new("object_tracing")
|
16
|
+
|
14
17
|
namespace :test do
|
15
18
|
task all: "appraisal:all"
|
16
19
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#include <ruby/ruby.h>
|
2
|
+
#include <ruby/debug.h>
|
3
|
+
|
4
|
+
static __thread uint64_t allocated_objects = 0;
|
5
|
+
|
6
|
+
static VALUE rb_mPlainApm;
|
7
|
+
static VALUE rb_mObjTracing;
|
8
|
+
|
9
|
+
static VALUE total_thread_allocated_objects(VALUE self) {
|
10
|
+
return ULL2NUM(allocated_objects);
|
11
|
+
}
|
12
|
+
|
13
|
+
static void track_thread_allocated_objects(VALUE tpval, void *data) {
|
14
|
+
allocated_objects++;
|
15
|
+
}
|
16
|
+
|
17
|
+
void Init_object_tracing(void) {
|
18
|
+
rb_mPlainApm = rb_define_module("PlainApm");
|
19
|
+
rb_mObjTracing = rb_define_module_under(rb_mPlainApm, "ObjectTracing");
|
20
|
+
|
21
|
+
rb_define_singleton_method(rb_mObjTracing, "total_thread_allocated_objects", total_thread_allocated_objects, 0);
|
22
|
+
|
23
|
+
VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ, track_thread_allocated_objects, NULL);
|
24
|
+
rb_tracepoint_enable(tpval);
|
25
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module PlainApm
|
2
|
+
module Extensions
|
3
|
+
module ThreadAllocations
|
4
|
+
def start!
|
5
|
+
super
|
6
|
+
@thread_allocation_count_start = now_thread_allocations
|
7
|
+
end
|
8
|
+
|
9
|
+
def finish!
|
10
|
+
super
|
11
|
+
@thread_allocation_count_finish = now_thread_allocations
|
12
|
+
end
|
13
|
+
|
14
|
+
def thread_allocations
|
15
|
+
@thread_allocation_count_finish - @thread_allocation_count_start
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
if defined?(PlainApm::ObjectTracing)
|
21
|
+
def now_thread_allocations
|
22
|
+
PlainApm::ObjectTracing.total_thread_allocated_objects
|
23
|
+
end
|
24
|
+
else
|
25
|
+
def now_thread_allocations
|
26
|
+
0
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if defined?(ActiveSupport)
|
32
|
+
ActiveSupport::Notifications::Event.prepend(PlainApm::Extensions::ThreadAllocations)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -21,7 +21,8 @@ module PlainApm
|
|
21
21
|
"backtrace" => filtered_backtrace,
|
22
22
|
"started_at" => event.time,
|
23
23
|
"finished_at" => event.end,
|
24
|
-
"allocations" => event.allocations
|
24
|
+
"allocations" => event.allocations,
|
25
|
+
"thread_allocations" => event.thread_allocations
|
25
26
|
}
|
26
27
|
|
27
28
|
case name
|
@@ -23,6 +23,7 @@ module PlainApm
|
|
23
23
|
"started_at" => event.time,
|
24
24
|
"finished_at" => event.end,
|
25
25
|
"allocations" => event.allocations,
|
26
|
+
"thread_allocations" => event.thread_allocations,
|
26
27
|
"queue_name" => job.queue_name,
|
27
28
|
"job_id" => job.job_id,
|
28
29
|
"job_class" => job.class.name,
|
@@ -23,7 +23,8 @@ module PlainApm
|
|
23
23
|
"backtrace" => filtered_backtrace,
|
24
24
|
"started_at" => event.time,
|
25
25
|
"finished_at" => event.end,
|
26
|
-
"allocations" => event.allocations
|
26
|
+
"allocations" => event.allocations,
|
27
|
+
"thread_allocations" => event.thread_allocations
|
27
28
|
}
|
28
29
|
|
29
30
|
case name
|
data/lib/plain_apm/version.rb
CHANGED
data/lib/plain_apm.rb
CHANGED
@@ -5,6 +5,8 @@ require_relative "plain_apm/transport"
|
|
5
5
|
require_relative "plain_apm/config"
|
6
6
|
require_relative "plain_apm/agent"
|
7
7
|
|
8
|
+
require "object_tracing"
|
9
|
+
|
8
10
|
require_relative "plain_apm/hooks/deploy"
|
9
11
|
|
10
12
|
# Rails extensions
|
@@ -15,6 +17,7 @@ begin
|
|
15
17
|
require_relative "plain_apm/extensions/context/middleware"
|
16
18
|
require_relative "plain_apm/extensions/context/active_job" if defined?(ActiveSupport)
|
17
19
|
require_relative "plain_apm/extensions/context/railtie" if defined?(Rails::Railtie)
|
20
|
+
require_relative "plain_apm/extensions/thread_allocations"
|
18
21
|
require_relative "plain_apm/helpers"
|
19
22
|
rescue LoadError
|
20
23
|
nil
|
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.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PlainAPM Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake-compiler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,7 +84,8 @@ description: Ruby gem to collect events/metrics and send them to PlainAPM.
|
|
70
84
|
email:
|
71
85
|
- support@plainapm.com
|
72
86
|
executables: []
|
73
|
-
extensions:
|
87
|
+
extensions:
|
88
|
+
- ext/object_tracing/extconf.rb
|
74
89
|
extra_rdoc_files: []
|
75
90
|
files:
|
76
91
|
- CHANGELOG.md
|
@@ -78,6 +93,8 @@ files:
|
|
78
93
|
- LICENSE.txt
|
79
94
|
- README.md
|
80
95
|
- Rakefile
|
96
|
+
- ext/object_tracing/extconf.rb
|
97
|
+
- ext/object_tracing/object_tracing.c
|
81
98
|
- lib/plain_apm.rb
|
82
99
|
- lib/plain_apm/agent.rb
|
83
100
|
- lib/plain_apm/backoff.rb
|
@@ -90,6 +107,7 @@ files:
|
|
90
107
|
- lib/plain_apm/extensions/exceptions/active_job.rb
|
91
108
|
- lib/plain_apm/extensions/exceptions/rack.rb
|
92
109
|
- lib/plain_apm/extensions/exceptions/railtie.rb
|
110
|
+
- lib/plain_apm/extensions/thread_allocations.rb
|
93
111
|
- lib/plain_apm/helpers.rb
|
94
112
|
- lib/plain_apm/hooks/action_mailer.rb
|
95
113
|
- lib/plain_apm/hooks/action_pack.rb
|