plain_apm 0.10.0 → 0.10.2

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: f234cdb0d7afa540ac0ae06405ca89a2476bf4e18a44062aebe6fda4868b8b63
4
- data.tar.gz: 1c3b2039cd4ce11b9d26d23a1dda6c9fba208fb2e3e8c50bccb0947e1f0161da
3
+ metadata.gz: 3c48770b73fc39349e83183e81f882964eee3504efb2828ca524651f6df8fcce
4
+ data.tar.gz: c591759e668fce2402e67b4d49cd2b91b2d74304f73f4979bad5862832455b79
5
5
  SHA512:
6
- metadata.gz: 7695a907666719056596c427615ca736b39e19a09ee5de97d6999eaec49a55b0a41853e6796076e5acc5e6433f3b8378cab802eadd682b27070b7e3bfe260a51
7
- data.tar.gz: d2ce1c8a4e12681f661c3b09307a32211cfcb3e65d449bb00f90b995bdb5ed4d9726db2edc6722e1d4a9c97a2035d3b6cc1f75d3e1767bf6f0baacdcfba71a36
6
+ metadata.gz: 202d04c8ddf30432c613bcda9abe0a6abb0b73de9fb0a40b57181cdd4e264837b20c641948f867955699227e726e369687454b9a0c8e5d1a00c0f5d4485c9aaa
7
+ data.tar.gz: c16dc0de9bb7bfa110eddb680d0a96da964a5a0ef98bcd1c4c75ea6fcb4f3adc4623bc9e0c7c9621e8a738f87986a5cb33f3cfe4341bb8a115e7b996609c3231
@@ -1,14 +1,19 @@
1
1
  #include <ruby/ruby.h>
2
2
  #include <ruby/debug.h>
3
3
 
4
+ /* Pre-ruby 3.1 compatibility */
5
+ #ifndef RBOOL
6
+ #define RBOOL(v) ((v) ? Qtrue : Qfalse)
7
+ #endif
8
+
4
9
  static VALUE rb_mPlainApm = Qnil;
5
10
  static VALUE rb_mObjTracing = Qnil;
6
11
 
7
12
  static __thread uint64_t allocated_objects = 0;
8
13
 
9
- #ifdef OBJECT_TRACING_ENABLED
10
14
  static int object_tracing_active = 0;
11
15
 
16
+ #ifdef OBJECT_TRACING_ENABLED
12
17
  static void track_thread_allocated_objects(VALUE tpval, void *data) {
13
18
  allocated_objects++;
14
19
  }
@@ -18,6 +23,10 @@ static VALUE total_thread_allocated_objects(VALUE self) {
18
23
  return ULL2NUM(allocated_objects);
19
24
  }
20
25
 
26
+ static VALUE thread_allocated_objects_tracing_enabled(VALUE self) {
27
+ return RBOOL(object_tracing_active);
28
+ }
29
+
21
30
  void Init_object_tracing(void) {
22
31
  rb_mPlainApm = rb_define_module("PlainApm");
23
32
  rb_gc_register_address(&rb_mPlainApm);
@@ -26,6 +35,7 @@ void Init_object_tracing(void) {
26
35
  rb_gc_register_address(&rb_mObjTracing);
27
36
 
28
37
  rb_define_singleton_method(rb_mObjTracing, "total_thread_allocated_objects", total_thread_allocated_objects, 0);
38
+ rb_define_singleton_method(rb_mObjTracing, "thread_allocated_objects_tracing_enabled", thread_allocated_objects_tracing_enabled, 0);
29
39
 
30
40
  #ifdef OBJECT_TRACING_ENABLED
31
41
  /* Ensure the tracepoint is attached only once. */
@@ -27,6 +27,9 @@ module PlainApm
27
27
  attrs[:message] = e.message
28
28
  attrs[:backtrace] = e.backtrace
29
29
 
30
+ attrs[:event_time] = now
31
+ attrs[:event_utc_time] = utc_now
32
+
30
33
  if error_source
31
34
  attrs[:event_source] = error_source
32
35
  end
@@ -83,6 +86,10 @@ module PlainApm
83
86
  attrs[:event_time] = event.time
84
87
  attrs[:duration] = event.duration
85
88
 
89
+ if event.respond_to?(:utc_time)
90
+ attrs[:event_utc_time] = event.utc_time
91
+ end
92
+
86
93
  if event.respond_to?(:gc_time)
87
94
  attrs[:gc_time] = event.gc_time
88
95
  end
@@ -115,7 +122,7 @@ module PlainApm
115
122
  # https://bugs.ruby-lang.org/issues/19443 for the feature.
116
123
  def add_trace_attributes(attrs)
117
124
  attrs[:thread_id] = Thread.current.object_id
118
- attrs[:collected_at] = Time.now.to_f
125
+ attrs[:collected_at] = utc_now
119
126
  attrs[:pid] = Process.pid
120
127
  attrs[:version] = PlainApm::VERSION
121
128
  attrs[:hostname] = cached_attributes[:hostname]
@@ -156,6 +163,14 @@ module PlainApm
156
163
  nil
157
164
  end
158
165
 
166
+ def now
167
+ Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
168
+ end
169
+
170
+ def utc_now
171
+ Time.now.to_f
172
+ end
173
+
159
174
  def self.included(other)
160
175
  other.class_eval do
161
176
  def self.rails_root
@@ -4,6 +4,7 @@ module PlainApm
4
4
  module Event
5
5
  def start!
6
6
  super
7
+ @utc_start = utc_now
7
8
  @thread_allocation_count_start = now_thread_allocations
8
9
  @gc_time_start = now_gc_time
9
10
  @gc_major_count_start = now_gc_major_count
@@ -34,6 +35,10 @@ module PlainApm
34
35
  @gc_minor_count_finish - @gc_minor_count_start
35
36
  end
36
37
 
38
+ def utc_time
39
+ @utc_start
40
+ end
41
+
37
42
  private
38
43
 
39
44
  # Per thread GC counter
@@ -71,6 +76,10 @@ module PlainApm
71
76
  0
72
77
  end
73
78
  end
79
+
80
+ def utc_now
81
+ Time.now.to_f
82
+ end
74
83
  end
75
84
  end
76
85
  end
@@ -26,7 +26,12 @@ module PlainApm
26
26
  o[:path] = payload[:path]
27
27
  o[:status] = payload[:status]
28
28
  end
29
- when "redirect_to", "start_processing", "halted_callback", "send_file", "send_data"
29
+ when "start_processing"
30
+ base.tap do |o|
31
+ o[:controller] = payload[:controller]
32
+ o[:action] = payload[:action]
33
+ end
34
+ when "redirect_to", "halted_callback", "send_file", "send_data"
30
35
  nil
31
36
  when "read_fragment", "write_fragment", "exist_fragment?", "expire_fragment"
32
37
  # controller, action, key
@@ -30,6 +30,9 @@ module PlainApm
30
30
  end
31
31
 
32
32
  def collect(event)
33
+ # drop immediately if there's no ongoing transaction
34
+ return if PlainApm::Extensions::Context.trace_id.nil?
35
+
33
36
  # id / transaction_id is by instrumenter and thread
34
37
  payload = payload(event)
35
38
 
@@ -93,6 +93,7 @@ module PlainApm
93
93
  {
94
94
  "Content-Type" => "application/json, charset=UTF-8",
95
95
  "Content-Encoding" => "deflate",
96
+ "X-PlainApm-Version" => PlainApm::VERSION,
96
97
  "X-PlainApm-Key" => app_key
97
98
  }.merge(meta_headers)
98
99
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlainApm
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.2"
5
5
  end
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.10.0
4
+ version: 0.10.2
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-04-17 00:00:00.000000000 Z
11
+ date: 2024-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.3.26
159
+ rubygems_version: 3.3.27
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: PlainAPM agent