columns_trace 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +13 -1
- data/lib/columns_trace/rails_integration.rb +9 -7
- data/lib/columns_trace/sidekiq_integration.rb +2 -4
- data/lib/columns_trace/version.rb +1 -1
- data/lib/columns_trace.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b9167813d7f9a2089f1eb2380bc62de8289384ed56f33fc4983ca716b76c0a9
|
4
|
+
data.tar.gz: 0ce77996e83a1af64bb9d64acc7231965e1a46263b9be30bb870a3e3a0a6a140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2f63e4cc55f26f7f86670c65378f203e8ea4e703ccd8079e5a4c201729eddb2de42277f654108ef80b61dc29c31ba5211a97fec44f05076480234e65a3221b5
|
7
|
+
data.tar.gz: 3fbddc61ae15705ecb191b3d1856f726b292c59d6973b80c4f464555765e423551572fea0e17a21e3019839b9b109e1f0803fc86db588ab9ac3752da8f3d6a3b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ $ bundle install
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
Hit a controller action or run `ActiveJob` (or `Sidekiq`) job, open `log/columns_trace.log`,
|
28
|
+
Hit a controller or email action or run `ActiveJob` (or `Sidekiq`) job, open `log/columns_trace.log`,
|
29
29
|
and see the output:
|
30
30
|
|
31
31
|
```
|
@@ -54,6 +54,18 @@ ImportProjectJob
|
|
54
54
|
↳ app/jobs/import_project_job.rb:24:in `perform'
|
55
55
|
```
|
56
56
|
|
57
|
+
### Tracing custom code
|
58
|
+
|
59
|
+
To get columns usage in the custom code, you can manually wrap it by `ColumnsTrace.report`:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
task my_rake_task: :environment do
|
63
|
+
ColumnsTrace.report("my_rake_task") do
|
64
|
+
# do stuff
|
65
|
+
end
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
57
69
|
## Configuration
|
58
70
|
|
59
71
|
You can override the following default options:
|
@@ -14,18 +14,20 @@ module ColumnsTrace
|
|
14
14
|
end
|
15
15
|
|
16
16
|
ActiveSupport.on_load(:action_controller) do
|
17
|
-
|
17
|
+
around_action do |controller, action|
|
18
|
+
ColumnsTrace.report("#{controller.class.name}##{action_name}", &action)
|
19
|
+
end
|
20
|
+
end
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
ActiveSupport.on_load(:action_mailer) do
|
23
|
+
around_action do |mailer, action|
|
24
|
+
ColumnsTrace.report("#{mailer.class.name}##{action_name}", &action)
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
28
|
ActiveSupport.on_load(:active_job) do
|
25
|
-
|
26
|
-
|
27
|
-
after_perform do
|
28
|
-
ColumnsTrace.reporter.report(self.class.name, Registry.created_records)
|
29
|
+
around_perform do |job, perform|
|
30
|
+
ColumnsTrace.report("#{job.class.name}#perform", &perform)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -3,10 +3,8 @@
|
|
3
3
|
module ColumnsTrace
|
4
4
|
# @private
|
5
5
|
class SidekiqMiddleware
|
6
|
-
def call(worker, _job, _queue)
|
7
|
-
|
8
|
-
yield
|
9
|
-
ColumnsTrace.reporter.report(worker.class.name, Registry.created_records)
|
6
|
+
def call(worker, _job, _queue, &block)
|
7
|
+
ColumnsTrace.report("#{worker.class.name}#perform", &block)
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
data/lib/columns_trace.rb
CHANGED
@@ -11,6 +11,23 @@ require_relative "columns_trace/railtie" if defined?(Rails)
|
|
11
11
|
|
12
12
|
module ColumnsTrace
|
13
13
|
class << self
|
14
|
+
# Manually trace columns usage in an arbitrary code.
|
15
|
+
#
|
16
|
+
# @param title [String] title of the reporting, e.g. controller action etc
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# task my_rake_task: :environment do
|
20
|
+
# ColumnsTrace.report("my_rake_task") do
|
21
|
+
# # do stuff
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
def report(title)
|
26
|
+
Registry.clear
|
27
|
+
yield
|
28
|
+
reporter.report(title, Registry.created_records)
|
29
|
+
end
|
30
|
+
|
14
31
|
# @private
|
15
32
|
attr_reader :ignored_models
|
16
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: columns_trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|