plain_apm 0.3.0 → 0.4.0

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: e496879797c3c3bedfeea9f641b9f113bae2104b6a3c69bb67fdd6cfd8734af6
4
- data.tar.gz: 484e1217d8d459ccf6c3619da23730c2126094136648a6c8fe15f5dbb63962b1
3
+ metadata.gz: 9c90c84af568ff044876f532e72d6275670a0866f13ca3bc81de6ef726ae4d4a
4
+ data.tar.gz: 3be569a19a2b5f7aed767336ba39490a56435608db9f387c52ca3980d0d5303c
5
5
  SHA512:
6
- metadata.gz: '052286dd61178482ed0c794f0486d28d21914bb250a77b86ec408599a25d6b6198baa844f34678ec6094ad84f3d3ec37ff2a5761ec89286527d19676ed1b7ef5'
7
- data.tar.gz: 51b7cbc86ff0c6c8595ffde40361713f41e206d0d73f63ef0bb8270454a3a62af16e5851a789c2c9c2367cb8ade92e36324d9acaca64bd1784cf81fe486ddf15
6
+ metadata.gz: 681bf3e9efd941ff2dbb88e38af19ffd96d6f790756b82e831f81e4ee33cc44f1d486aac53ca0417fd1fb3990a8b19811563473d765087d96b400e3f33708f84
7
+ data.tar.gz: b5a9cd30b8fd458a95ecfb8f2e9caf5c9e6b2a6d2e98c4ad7446c06ea5539efb8eca38b35a58fd9c3578e45a5a3272c2febac68bdca092ae4283330562783145
@@ -72,7 +72,8 @@ module PlainApm
72
72
  Hooks::ActionView,
73
73
  Hooks::ActiveJob,
74
74
  Hooks::ActiveRecord,
75
- Hooks::ErrorReporter
75
+ Hooks::ErrorReporter,
76
+ Hooks::Manual
76
77
  ].map(&:new).each(&:install)
77
78
  end
78
79
 
@@ -0,0 +1,12 @@
1
+ module PlainApm
2
+ module Helpers
3
+ def plain_apm_context(context = {})
4
+ PlainApm::Extensions::Context.context.merge!(context)
5
+ end
6
+
7
+ def plain_apm_instrument(name, context = {}, &block)
8
+ sanitized_name = name.gsub(/\W/, "_").gsub(/(?!^)([A-Z])/) { |m| "_#{m}" }.gsub(/_+/, "_").downcase
9
+ ActiveSupport::Notifications.instrument("#{sanitized_name}.manual.plain_apm", **context, &block)
10
+ end
11
+ end
12
+ end
@@ -18,7 +18,13 @@ module PlainApm
18
18
  tool, revision = *result
19
19
 
20
20
  Agent.instance.collect(
21
- {"source" => tool, "revision" => revision, "name" => "deploy"}
21
+ {
22
+ "source" => tool,
23
+ "revision" => revision,
24
+ "name" => "deploy",
25
+ "started_at" => Time.now.to_f,
26
+ "finished_at" => Time.now.to_f
27
+ }
22
28
  )
23
29
  end
24
30
 
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PlainApm
4
+ module Hooks
5
+ class Manual < ActiveSupportSubscriber
6
+ NOTIFICATION_PATTERN = /\A[^!]\w+\.manual\.plain_apm\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
+
17
+ {
18
+ "source" => source,
19
+ "name" => name,
20
+ "backtrace" => filtered_backtrace,
21
+ "started_at" => event.time,
22
+ "finished_at" => event.end,
23
+ "allocations" => event.allocations,
24
+ "payload" => event.payload
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlainApm
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/plain_apm.rb CHANGED
@@ -12,10 +12,10 @@ begin
12
12
  require "rack/body_proxy"
13
13
 
14
14
  require_relative "plain_apm/extensions/context"
15
- require_relative "plain_apm/extensions/context/helpers"
16
15
  require_relative "plain_apm/extensions/context/middleware"
17
16
  require_relative "plain_apm/extensions/context/active_job" if defined?(ActiveSupport)
18
17
  require_relative "plain_apm/extensions/context/railtie" if defined?(Rails::Railtie)
18
+ require_relative "plain_apm/helpers"
19
19
  rescue LoadError
20
20
  nil
21
21
  end
@@ -31,6 +31,7 @@ require_relative "plain_apm/hooks/action_pack"
31
31
  require_relative "plain_apm/hooks/action_view"
32
32
  require_relative "plain_apm/hooks/active_job"
33
33
  require_relative "plain_apm/hooks/active_record"
34
+ require_relative "plain_apm/hooks/manual"
34
35
  require_relative "plain_apm/hooks/error_reporter"
35
36
 
36
37
  module PlainApm
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.3.0
4
+ version: 0.4.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-07 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -85,12 +85,12 @@ files:
85
85
  - lib/plain_apm/extensions/context.rb
86
86
  - lib/plain_apm/extensions/context/LICENSE.txt
87
87
  - lib/plain_apm/extensions/context/active_job.rb
88
- - lib/plain_apm/extensions/context/helpers.rb
89
88
  - lib/plain_apm/extensions/context/middleware.rb
90
89
  - lib/plain_apm/extensions/context/railtie.rb
91
90
  - lib/plain_apm/extensions/exceptions/active_job.rb
92
91
  - lib/plain_apm/extensions/exceptions/rack.rb
93
92
  - lib/plain_apm/extensions/exceptions/railtie.rb
93
+ - lib/plain_apm/helpers.rb
94
94
  - lib/plain_apm/hooks/action_mailer.rb
95
95
  - lib/plain_apm/hooks/action_pack.rb
96
96
  - lib/plain_apm/hooks/action_view.rb
@@ -99,6 +99,7 @@ files:
99
99
  - lib/plain_apm/hooks/active_support_subscriber.rb
100
100
  - lib/plain_apm/hooks/deploy.rb
101
101
  - lib/plain_apm/hooks/error_reporter.rb
102
+ - lib/plain_apm/hooks/manual.rb
102
103
  - lib/plain_apm/transport.rb
103
104
  - lib/plain_apm/version.rb
104
105
  homepage: https://plainapm.com
@@ -1,11 +0,0 @@
1
- module PlainApm
2
- module Extensions
3
- module Context
4
- module Helpers
5
- def plain_apm_context(context = {})
6
- PlainApm::Extensions::Context.context.merge!(context)
7
- end
8
- end
9
- end
10
- end
11
- end