plain_apm 0.4.0 → 0.5.0

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: 9c90c84af568ff044876f532e72d6275670a0866f13ca3bc81de6ef726ae4d4a
4
- data.tar.gz: 3be569a19a2b5f7aed767336ba39490a56435608db9f387c52ca3980d0d5303c
3
+ metadata.gz: 5d7ba5044b9386fbcbfb252e35649da1ad0b7573880510e0588323e24cf0bc11
4
+ data.tar.gz: 0ae2df2fea0bdbfc798be93a739a5b6d9144db045f38905feddd5e0975d852fd
5
5
  SHA512:
6
- metadata.gz: 681bf3e9efd941ff2dbb88e38af19ffd96d6f790756b82e831f81e4ee33cc44f1d486aac53ca0417fd1fb3990a8b19811563473d765087d96b400e3f33708f84
7
- data.tar.gz: b5a9cd30b8fd458a95ecfb8f2e9caf5c9e6b2a6d2e98c4ad7446c06ea5539efb8eca38b35a58fd9c3578e45a5a3272c2febac68bdca092ae4283330562783145
6
+ metadata.gz: f8af4f98d0e30a361e8c2aaf5ef6a3e31d5e1c533ea74b5bebcb03fde4069ef70d8ad9e8067d3c2d99bcaac0e1a73a03f847ef0b80c3ee6bea2be89c4829ec35
7
+ data.tar.gz: 007fab263d50573c67f710854ad60a6a3b4392e71599de2b6ed5f287bd63f7814e457c281f9135f130f78446b25af97be1669dcbc8d8ba731f78c16591d094ec
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,6 @@
1
+ require 'mkmf'
2
+
3
+ have_header('ruby/ruby.h') or missing('ruby/ruby.h')
4
+ have_header('ruby/debug.h') or missing('ruby/debug.h')
5
+
6
+ create_makefile('object_tracing')
@@ -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_module_function(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
@@ -20,6 +20,7 @@ module PlainApm
20
20
  "name" => name,
21
21
  "backtrace" => filtered_backtrace,
22
22
  "allocations" => event.allocations,
23
+ "thread_allocations" => event.thread_allocations,
23
24
  "started_at" => event.time,
24
25
  "finished_at" => event.end
25
26
  }
@@ -20,6 +20,7 @@ module PlainApm
20
20
  "name" => name,
21
21
  "backtrace" => filtered_backtrace,
22
22
  "allocations" => event.allocations,
23
+ "thread_allocations" => event.thread_allocations,
23
24
  "started_at" => event.time,
24
25
  "finished_at" => event.end
25
26
  }
@@ -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
@@ -21,6 +21,7 @@ module PlainApm
21
21
  "started_at" => event.time,
22
22
  "finished_at" => event.end,
23
23
  "allocations" => event.allocations,
24
+ "thread_allocations" => event.thread_allocations,
24
25
  "payload" => event.payload
25
26
  }
26
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlainApm
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
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.0
4
+ version: 0.5.0
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-10-27 00:00:00.000000000 Z
11
+ date: 2022-11-02 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