plain_apm 0.5.6 → 0.6.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: ae9d484b8cae829dc9a8159030fb3075493b7a164fc007c2f7a4688e5f0e7657
4
- data.tar.gz: 5c0e75c7ed7c549c13de43d44e8ff3733bda46d38994b77af93d48782a2855a3
3
+ metadata.gz: 127051af59250da7ce13cfc7c819caff29fb954d20399398e72eaf02ae3fecc4
4
+ data.tar.gz: 3c3f321becb4e79da27c6a09194c44fc5ec11a73f9e70a9ff55ce7833984fb73
5
5
  SHA512:
6
- metadata.gz: 74432ea0610f7d525e77aa2173de4adba0f723d713b5870d4a5dfdda1bf3fdb8e812b4b7b08b55d7c3729415d98890d2dd491bb0e94922cb8e8fa6d8a98916a1
7
- data.tar.gz: b5d84121648c14f64dbb76c4c7a9e040283465f0d9a9263dcf48292e6c2e3a604714e00a480f323b40fce13e80047890b4c6f7c7b269e0edaac7b3c0645f0fd9
6
+ metadata.gz: 752b27ebb2ab36147e85af199e939a25a666a738a772077a23ea3033577e966d0afbc773c1bd3f5614c1815deb7ca32395b49628de6b487a4bd214ad96955b27
7
+ data.tar.gz: 40d0f21220a4e118abcb767951730c743ac89787d9cfa6b2d421cad597c2e38ab5fae56ccc0fb9dd6b707d2344343660680440d6df089241fb2b8e579e0709fb
@@ -73,6 +73,7 @@ module PlainApm
73
73
  Hooks::ActionView,
74
74
  Hooks::ActiveJob,
75
75
  Hooks::ActiveRecord,
76
+ Hooks::ActiveSupport,
76
77
  Hooks::ErrorReporter,
77
78
  Hooks::Manual
78
79
  ].map(&:new).each(&:install)
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PlainApm
4
+ module Hooks
5
+ class ActiveSupport < ActiveSupportSubscriber
6
+ NOTIFICATION_PATTERN = /\Acache_[\w\?]+\.active_support\Z/.freeze
7
+
8
+ private
9
+
10
+ def notification_pattern
11
+ NOTIFICATION_PATTERN
12
+ end
13
+
14
+ def payload(event)
15
+ name, source = *event.name.split(".")
16
+ payload = event.payload
17
+
18
+ base = {
19
+ "source" => source,
20
+ "name" => name,
21
+ "backtrace" => filtered_backtrace,
22
+ "started_at" => event.time,
23
+ "finished_at" => event.end,
24
+ "allocations" => event.allocations,
25
+ "thread_allocations" => event.thread_allocations,
26
+ "store" => payload[:store]
27
+ }
28
+
29
+ case name
30
+ when "cache_read"
31
+ base.merge({
32
+ "key" => payload[:key],
33
+ "hit" => payload[:hit],
34
+ "trigger" => payload[:super_operation],
35
+ })
36
+ when "cache_read_multi"
37
+ base.merge({
38
+ "keys" => payload[:key],
39
+ "hits" => payload[:hits]
40
+ })
41
+ when "cache_fetch_hit"
42
+ base.merge({
43
+ "key" => payload[:key],
44
+ "hit" => true
45
+ })
46
+ when "cache_write", "cache_write_multi", "cache_generate", "cache_delete", "cache_delete_matched", "cache_exist?"
47
+ base.merge({
48
+ "key" => payload[:key]
49
+ })
50
+ when "cache_increment", "cache_decrement"
51
+ base.merge({
52
+ "key" => payload[:key],
53
+ "amount" => payload[:amount]
54
+ })
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -10,7 +10,7 @@ module PlainApm
10
10
  return
11
11
  end
12
12
 
13
- asn = ActiveSupport::Notifications
13
+ asn = ::ActiveSupport::Notifications
14
14
 
15
15
  # Rails >= 6.1
16
16
  if asn.respond_to?(:monotonic_subscribe)
@@ -17,7 +17,7 @@ module PlainApm
17
17
 
18
18
  # Install the hook when the app is up. This might miss errors that
19
19
  # happen before that, but that's OK.
20
- ActiveSupport.on_load(:after_initialize, yield: self, run_once: true) do
20
+ ::ActiveSupport.on_load(:after_initialize, yield: self, run_once: true) do
21
21
  ::Rails.error.subscribe(self)
22
22
  end
23
23
  end
@@ -36,6 +36,13 @@ module PlainApm
36
36
  "context" => context
37
37
  }
38
38
 
39
+ if context[:job] && context[:job].is_a?(ActiveJob::Base)
40
+ event.merge!({
41
+ "job_class" => context[:job].class.name,
42
+ "queue_name" => context[:job].queue_name
43
+ })
44
+ end
45
+
39
46
  if e.cause
40
47
  event.merge!({
41
48
  "cause_class" => e.cause.class.name,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlainApm
4
- VERSION = "0.5.6"
4
+ VERSION = "0.6.1"
5
5
  end
data/lib/plain_apm.rb CHANGED
@@ -34,6 +34,7 @@ require_relative "plain_apm/hooks/action_pack"
34
34
  require_relative "plain_apm/hooks/action_view"
35
35
  require_relative "plain_apm/hooks/active_job"
36
36
  require_relative "plain_apm/hooks/active_record"
37
+ require_relative "plain_apm/hooks/active_support"
37
38
  require_relative "plain_apm/hooks/manual"
38
39
  require_relative "plain_apm/hooks/error_reporter"
39
40
 
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.5.6
4
+ version: 0.6.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-12-12 00:00:00.000000000 Z
11
+ date: 2022-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -114,6 +114,7 @@ files:
114
114
  - lib/plain_apm/hooks/action_view.rb
115
115
  - lib/plain_apm/hooks/active_job.rb
116
116
  - lib/plain_apm/hooks/active_record.rb
117
+ - lib/plain_apm/hooks/active_support.rb
117
118
  - lib/plain_apm/hooks/active_support_subscriber.rb
118
119
  - lib/plain_apm/hooks/deploy.rb
119
120
  - lib/plain_apm/hooks/error_reporter.rb