vx-instrumentation 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 8e38ae361a2d539a48365d64eaeb9cc905934c7b
4
- data.tar.gz: 8eb4ea7ba4eacceb47cda77958dc1e4f4f3919c8
3
+ metadata.gz: 9178f6d2a8a76a723de0d0ae4c88937f290e6e66
4
+ data.tar.gz: 9718fd7ca3ab06054ad1f98fe8c6f98bef81eaf3
5
5
  SHA512:
6
- metadata.gz: a836d117ec05ce5200a9093ee69ad74d0e16cd86ac8e9109f6a3f14636e81721566e961a74ace09274959340ee62cabe9acd33827943046a374c5b4fce53ac4e
7
- data.tar.gz: 3649718e03c7c01187f0553634da00ebae0965df4c2db2658587ce3585e1bcebcf2eb0b018a9a06d53b94c953b8ce792eb737faa83ca92f3081950769b6afbf4
6
+ metadata.gz: 259a62ac21ff478952e099b121fde6a0a34fd9860b9727790c34aa506fba8af14523fcbce6cac07fbc81b2d1e2be5e0ebbb9c22097fb08efb1a380a88fd62660
7
+ data.tar.gz: 6cad4995cff09cd4c4c15b219dd904ed5b8487c3af53b68b05f58ca5e8d28976151bde9d7cf8e120e878c66546bd4f762cb4afedd5f755300d20b6744a64eaa6
@@ -21,6 +21,13 @@ module Vx
21
21
  Instrumentation::Logger.logger.level = log_level
22
22
  end
23
23
 
24
+ def activate(*probes)
25
+ probes.each do |probe|
26
+ require File.expand_path("../instrumentation/probe/#{probe}", __FILE__)
27
+ $stdout.puts " --> activate instrumentations for #{probe}"
28
+ end
29
+ end
30
+
24
31
  def with(new_keys)
25
32
  old_keys = Thread.current[THREAD_KEY]
26
33
  begin
@@ -0,0 +1,6 @@
1
+ require 'active_support/notifications'
2
+
3
+ ActiveSupport::Notifications.subscribe(/\.action_controller$/) do |event, started, finished, _, payload|
4
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
5
+ end
6
+
@@ -0,0 +1,15 @@
1
+ require 'active_support/notifications'
2
+
3
+ ActiveSupport::Notifications.subscribe(/\.action_dispatch$/) do |event, started, finished, _, payload|
4
+ req = payload[:request]
5
+ payload = {
6
+ path: req.fullpath,
7
+ ip: req.remote_ip,
8
+ method: req.method,
9
+ referer: req.referer,
10
+ content_length: req.content_length,
11
+ user_agent: req.user_agent
12
+ }
13
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
14
+ end
15
+
@@ -0,0 +1,6 @@
1
+ require 'active_support/notifications'
2
+
3
+ ActiveSupport::Notifications.subscribe(/\.action_mailer$/) do |event, started, finished, _, payload|
4
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
5
+ end
6
+
@@ -0,0 +1,8 @@
1
+ require 'active_support/notifications'
2
+ require 'vx/instrumentation'
3
+
4
+ ActiveSupport::Notifications.subscribe(/\.action_view$/) do |event, started, finished, _, payload|
5
+ if event[0] != "!"
6
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ require 'active_support/notifications'
2
+
3
+ ActiveSupport::Notifications.subscribe(/\.active_record$/) do |event, started, finished, _, payload|
4
+
5
+ binds =
6
+ (payload[:binds] || []).map do |column, value|
7
+ if column
8
+ if column.binary?
9
+ value = "<#{value.bytesize} bytes of binary data>"
10
+ end
11
+ [column.name, value]
12
+ else
13
+ [nil, value]
14
+ end
15
+ end.inspect
16
+
17
+ payload = {
18
+ sql: payload[:sql],
19
+ binds: binds,
20
+ name: payload[:name],
21
+ duration: payload[:duration]
22
+ }
23
+
24
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
25
+ end
26
+
@@ -0,0 +1,6 @@
1
+ require 'active_support/notifications'
2
+
3
+ ActiveSupport::Notifications.subscribe(/\.active_support$/) do |event, started, finished, _, payload|
4
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
5
+ end
6
+
@@ -0,0 +1,24 @@
1
+ require 'active_support/notifications'
2
+
3
+ ActiveSupport::Notifications.subscribe(/\.faraday$/) do |event, started, finished, _, payload|
4
+
5
+ render_http_header = ->(headers) {
6
+ (headers || []).map do |key,value|
7
+ if %{ PRIVATE-TOKEN Authorization }.include?(key)
8
+ value = value.gsub(/./, "*")
9
+ end
10
+ "#{key}: #{value}"
11
+ end.join("\n")
12
+ }
13
+
14
+ payload = {
15
+ method: payload[:method],
16
+ url: payload[:url].to_s,
17
+ status: payload[:status],
18
+ response_headers: render_http_header.call(payload[:response_headers]),
19
+ request_headers: render_http_header.call(payload[:request_headers])
20
+ }
21
+
22
+ Vx::Instrumentation.delivery event, payload, event.split("."), started, finished
23
+ end
24
+
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module Instrumentation
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky
@@ -82,6 +82,13 @@ files:
82
82
  - Rakefile
83
83
  - lib/vx/instrumentation.rb
84
84
  - lib/vx/instrumentation/logger.rb
85
+ - lib/vx/instrumentation/probe/action_controller.rb
86
+ - lib/vx/instrumentation/probe/action_dispatch.rb
87
+ - lib/vx/instrumentation/probe/action_mailer.rb
88
+ - lib/vx/instrumentation/probe/action_view.rb
89
+ - lib/vx/instrumentation/probe/active_record.rb
90
+ - lib/vx/instrumentation/probe/active_support.rb
91
+ - lib/vx/instrumentation/probe/faraday.rb
85
92
  - lib/vx/instrumentation/rack/handle_exceptions_middleware.rb
86
93
  - lib/vx/instrumentation/stderr.rb
87
94
  - lib/vx/instrumentation/version.rb