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 +4 -4
- data/lib/vx/instrumentation.rb +7 -0
- data/lib/vx/instrumentation/probe/action_controller.rb +6 -0
- data/lib/vx/instrumentation/probe/action_dispatch.rb +15 -0
- data/lib/vx/instrumentation/probe/action_mailer.rb +6 -0
- data/lib/vx/instrumentation/probe/action_view.rb +8 -0
- data/lib/vx/instrumentation/probe/active_record.rb +26 -0
- data/lib/vx/instrumentation/probe/active_support.rb +6 -0
- data/lib/vx/instrumentation/probe/faraday.rb +24 -0
- data/lib/vx/instrumentation/version.rb +1 -1
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9178f6d2a8a76a723de0d0ae4c88937f290e6e66
|
4
|
+
data.tar.gz: 9718fd7ca3ab06054ad1f98fe8c6f98bef81eaf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 259a62ac21ff478952e099b121fde6a0a34fd9860b9727790c34aa506fba8af14523fcbce6cac07fbc81b2d1e2be5e0ebbb9c22097fb08efb1a380a88fd62660
|
7
|
+
data.tar.gz: 6cad4995cff09cd4c4c15b219dd904ed5b8487c3af53b68b05f58ca5e8d28976151bde9d7cf8e120e878c66546bd4f762cb4afedd5f755300d20b6744a64eaa6
|
data/lib/vx/instrumentation.rb
CHANGED
@@ -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,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,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,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
|
+
|
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.
|
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
|