plain_apm 0.9.8 → 0.10.1

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: 72d2d8915ce85d5a10557fd615a6011840b329155bc0d8765c1a5cef05383bc3
4
- data.tar.gz: e9473490d411042af5e1cc04d7374ebb6b8f7b5c07aebaaa0bda604ca0bfb3a2
3
+ metadata.gz: 380c7c5a078b9d9b650e66ea7daa26109e3a028af6733c845da95784a9848351
4
+ data.tar.gz: 4e72c60ed9f5bf063802d27c8b98fe63b236d74eed7b06e9c9aa0bcc0f0d175d
5
5
  SHA512:
6
- metadata.gz: 7230625a30f50a3777ba5364544979b3edf1718b752836791b4c66997bb4988ca3e8311b1a11ddbefd8de4c0c80f2bae6761532fc0a08567d7b09b67d65a2062
7
- data.tar.gz: ff5e0376280f779a9ce2e4cd8cab148d61bf87c8280406b43a71aa409c63974d149afd727540774e564c9d383788d69b9cc533d90bd64849e86ff8f6763db536
6
+ metadata.gz: bb81d0e597f83f1fe6389fc1732a7c165d69d3e3369ac2b73152de6566ef5c06e1002d910b4dc6b46e0f69b44c4bfb72c33540b62910f3dbc6db8b0b023655fb
7
+ data.tar.gz: 4a371c933a3dae7778c80b1f01479048194e60f61929b7fab3eff0b5dffc69144df419f1b92f65545a16a014dade2d4bb318ec33480bd4b885eb02a0d620b074
@@ -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. */
@@ -19,11 +19,11 @@ module PlainApm
19
19
  end
20
20
 
21
21
  def key_present?
22
- ENV["PLAIN_APM_APP_KEY"] != ""
22
+ ENV["PLAIN_APM_APP_KEY"].to_s != ""
23
23
  end
24
24
 
25
25
  def production?
26
- (ENV["RAILS_ENV"] || ENV["RACK_ENV"]) == "production"
26
+ (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["APP_ENV"]) == "production"
27
27
  end
28
28
 
29
29
  def interactive?
@@ -16,7 +16,7 @@ module PlainApm
16
16
  end
17
17
 
18
18
  def heroku_revision
19
- rev = ENV["HEROKU_SLUG_COMMIT"].to_s[0..8]
19
+ rev = ENV.fetch("GIT_REV", ENV.fetch("HEROKU_SLUG_COMMIT", ""))[0...8]
20
20
  rev if !rev.empty?
21
21
  end
22
22
 
@@ -17,9 +17,9 @@ module PlainApm
17
17
  ].freeze
18
18
 
19
19
  def attributes_from_exception(e, context, error_source)
20
- source = "exception"
20
+ name = "exception"
21
21
 
22
- return [source, nil] if IGNORED_EXCEPTIONS.include?(e.class.name)
22
+ return [name, nil] if IGNORED_EXCEPTIONS.include?(e.class.name)
23
23
 
24
24
  attrs = context_attributes
25
25
 
@@ -67,7 +67,7 @@ module PlainApm
67
67
 
68
68
  add_trace_attributes(attrs)
69
69
 
70
- [source, attrs]
70
+ [name, attrs]
71
71
  end
72
72
 
73
73
  def attributes_from_notification(event)
@@ -25,12 +25,12 @@ module PlainApm
25
25
  private
26
26
 
27
27
  def report_exception(e, env)
28
- source, event = attributes_from_exception(e, {env: env}, nil)
28
+ name, event = attributes_from_exception(e, {env: env}, nil)
29
29
 
30
30
  return if event.nil?
31
31
 
32
- event[:source] = source
33
- event[:name] = "rack_middleware"
32
+ event[:source] = "rack_middleware"
33
+ event[:name] = name
34
34
 
35
35
  PlainApm.agent.collect(event)
36
36
  end
@@ -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
 
@@ -23,12 +23,12 @@ module PlainApm
23
23
  end
24
24
 
25
25
  def collect(e, handled:, severity:, context: {}, source: nil)
26
- event_source, event = attributes_from_exception(e, context, source)
26
+ name, event = attributes_from_exception(e, context, source)
27
27
 
28
28
  return if event.nil?
29
29
 
30
- event[:source] = event_source
31
- event[:name] = "error_reporter"
30
+ event[:source] = "error_reporter"
31
+ event[:name] = name
32
32
 
33
33
  ::PlainApm.agent.collect(event)
34
34
  end
@@ -92,7 +92,8 @@ module PlainApm
92
92
 
93
93
  {
94
94
  "Content-Type" => "application/json, charset=UTF-8",
95
- "Content-Encoding" => "gzip",
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.9.8"
4
+ VERSION = "0.10.1"
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.9.8
4
+ version: 0.10.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: 2024-04-08 00:00:00.000000000 Z
11
+ date: 2024-05-11 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