trace_location 0.9.3 → 0.9.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +41 -316
- data/examples/active_record_establish_connection/result.csv +265 -0
- data/examples/active_record_establish_connection/result.log +271 -0
- data/examples/active_record_establish_connection/result.md +2279 -0
- data/examples/active_record_validation_process/result.csv +11 -0
- data/examples/active_record_validation_process/result.log +17 -0
- data/examples/active_record_validation_process/result.md +69 -0
- data/examples/has_secure_password/result.csv +41 -0
- data/examples/has_secure_password/result.log +47 -0
- data/examples/has_secure_password/result.md +395 -0
- data/examples/lifecycle_of_rails_application/result.csv +2769 -0
- data/examples/lifecycle_of_rails_application/result.log +2775 -0
- data/examples/lifecycle_of_rails_application/result.md +21437 -0
- data/examples/rendering_process/result.csv +617 -0
- data/examples/rendering_process/result.log +623 -0
- data/examples/rendering_process/result.md +4414 -0
- data/lib/trace_location/collector.rb +6 -2
- data/lib/trace_location/config.rb +2 -2
- data/lib/trace_location/generator/csv.rb +12 -2
- data/lib/trace_location/generator/log.rb +6 -7
- data/lib/trace_location/generator/markdown.rb +5 -4
- data/lib/trace_location/version.rb +1 -1
- metadata +17 -3
- data/CHANGELOG.md +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53f06873752fb59bd283cfdab5418d69be411bd03d9dcb9c73aebfefacf1286
|
4
|
+
data.tar.gz: 75d433e5b116f864e2393bea2417949335775aa619be186eb6c145268283f779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6206f594de72240102b08f14e2620924d9e0310393305c55266b743f3a28e3af22fe018ffa429f2eb19e07a95a707511c6550b239357227b3dc792e11a78041d
|
7
|
+
data.tar.gz: 6ad2e38892b0794c714345da2ef873f71f329983ceb679a068db0496ff982fea77f0bc886c01ea2bf3fd42f119082446921147f752cef1a1b10c9f7e704cf656
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,355 +20,80 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### Example: Track establish connection in Active Record
|
24
24
|
|
25
|
-
### Example 01. Track the validation process of Active Record
|
26
|
-
|
27
|
-
```
|
28
|
-
% bin/rails c
|
29
|
-
|
30
|
-
irb(main):001:0> book = Book.new(title: "My Book Title")
|
31
|
-
irb(main):002:0> TraceLocation.trace(ignore: /active_support/) { book.validate }
|
32
|
-
Created at /path/to/sampleapp/log/trace_location-2019060401061559579741.md
|
33
|
-
=> true
|
34
|
-
```
|
35
|
-
|
36
|
-
Then you can get a markdown file like this:
|
37
|
-
|
38
|
-
--
|
39
|
-
|
40
|
-
Generated by [trace_location](https://github.com/yhirano55/trace_location) at 2019-06-04 01:35:41 +0900
|
41
|
-
|
42
|
-
<details open>
|
43
|
-
<summary>activerecord-5.2.3/lib/active_record/validations.rb:65</summary>
|
44
|
-
|
45
|
-
##### ActiveRecord::Validations#valid?
|
46
|
-
```ruby
|
47
|
-
def valid?(context = nil)
|
48
|
-
context ||= default_validation_context
|
49
|
-
output = super(context)
|
50
|
-
errors.empty? && output
|
51
|
-
end
|
52
|
-
# called from (irb):2
|
53
|
-
```
|
54
|
-
|
55
|
-
</details>
|
56
|
-
<details open>
|
57
|
-
<summary>activerecord-5.2.3/lib/active_record/validations.rb:75</summary>
|
58
|
-
|
59
|
-
##### ActiveRecord::Validations#default_validation_context
|
60
|
-
```ruby
|
61
|
-
def default_validation_context
|
62
|
-
new_record? ? :create : :update
|
63
|
-
end
|
64
|
-
# called from activerecord-5.2.3/lib/active_record/validations.rb:66
|
65
|
-
```
|
66
|
-
|
67
|
-
</details>
|
68
|
-
<details open>
|
69
|
-
<summary>activerecord-5.2.3/lib/active_record/persistence.rb:231</summary>
|
70
|
-
|
71
|
-
##### ActiveRecord::Persistence#new_record?
|
72
|
-
```ruby
|
73
|
-
def new_record?
|
74
|
-
sync_with_transaction_state
|
75
|
-
@new_record
|
76
|
-
end
|
77
|
-
# called from activerecord-5.2.3/lib/active_record/validations.rb:76
|
78
|
-
```
|
79
|
-
|
80
|
-
</details>
|
81
|
-
<details open>
|
82
|
-
<summary>activerecord-5.2.3/lib/active_record/transactions.rb:490</summary>
|
83
|
-
|
84
|
-
##### ActiveRecord::Transactions#sync_with_transaction_state
|
85
|
-
```ruby
|
86
|
-
def sync_with_transaction_state
|
87
|
-
update_attributes_from_transaction_state(@transaction_state)
|
88
|
-
end
|
89
|
-
# called from activerecord-5.2.3/lib/active_record/persistence.rb:232
|
90
|
-
```
|
91
|
-
|
92
|
-
</details>
|
93
|
-
<details open>
|
94
|
-
<summary>activerecord-5.2.3/lib/active_record/transactions.rb:494</summary>
|
95
|
-
|
96
|
-
##### ActiveRecord::Transactions#update_attributes_from_transaction_state
|
97
|
-
```ruby
|
98
|
-
def update_attributes_from_transaction_state(transaction_state)
|
99
|
-
if transaction_state && transaction_state.finalized?
|
100
|
-
restore_transaction_record_state(transaction_state.fully_rolledback?) if transaction_state.rolledback?
|
101
|
-
force_clear_transaction_record_state if transaction_state.fully_committed?
|
102
|
-
clear_transaction_record_state if transaction_state.fully_completed?
|
103
|
-
end
|
104
|
-
end
|
105
|
-
# called from activerecord-5.2.3/lib/active_record/transactions.rb:491
|
106
|
-
```
|
107
|
-
|
108
|
-
</details>
|
109
|
-
<details open>
|
110
|
-
<summary>activemodel-5.2.3/lib/active_model/validations.rb:336</summary>
|
111
|
-
|
112
|
-
##### ActiveModel::Validations#valid?
|
113
|
-
```ruby
|
114
|
-
def valid?(context = nil)
|
115
|
-
current_context, self.validation_context = validation_context, context
|
116
|
-
errors.clear
|
117
|
-
run_validations!
|
118
|
-
ensure
|
119
|
-
self.validation_context = current_context
|
120
|
-
end
|
121
|
-
# called from activerecord-5.2.3/lib/active_record/validations.rb:67
|
122
|
-
```
|
123
|
-
|
124
|
-
</details>
|
125
|
-
<details open>
|
126
|
-
<summary>activemodel-5.2.3/lib/active_model/validations.rb:303</summary>
|
127
|
-
|
128
|
-
##### ActiveModel::Validations#errors
|
129
|
-
```ruby
|
130
|
-
def errors
|
131
|
-
@errors ||= Errors.new(self)
|
132
|
-
end
|
133
|
-
# called from activemodel-5.2.3/lib/active_model/validations.rb:338
|
134
|
-
```
|
135
|
-
|
136
|
-
</details>
|
137
|
-
<details open>
|
138
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:74</summary>
|
139
|
-
|
140
|
-
##### ActiveModel::Errors#initialize
|
141
|
-
```ruby
|
142
|
-
def initialize(base)
|
143
|
-
@base = base
|
144
|
-
@messages = apply_default_array({})
|
145
|
-
@details = apply_default_array({})
|
146
|
-
end
|
147
|
-
# called from activemodel-5.2.3/lib/active_model/validations.rb:304
|
148
|
-
```
|
149
|
-
|
150
|
-
</details>
|
151
|
-
<details open>
|
152
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:470</summary>
|
153
|
-
|
154
|
-
##### ActiveModel::Errors#apply_default_array
|
155
|
-
```ruby
|
156
|
-
def apply_default_array(hash)
|
157
|
-
hash.default_proc = proc { |h, key| h[key] = [] }
|
158
|
-
hash
|
159
|
-
end
|
160
|
-
# called from activemodel-5.2.3/lib/active_model/errors.rb:76
|
161
|
-
```
|
162
|
-
|
163
|
-
</details>
|
164
|
-
<details open>
|
165
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:470</summary>
|
166
|
-
|
167
|
-
##### ActiveModel::Errors#apply_default_array
|
168
25
|
```ruby
|
169
|
-
|
170
|
-
hash.default_proc = proc { |h, key| h[key] = [] }
|
171
|
-
hash
|
172
|
-
end
|
173
|
-
# called from activemodel-5.2.3/lib/active_model/errors.rb:77
|
174
|
-
```
|
26
|
+
config = Rails.application.config.database_configuration[Rails.env]
|
175
27
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
##### ActiveModel::Errors#clear
|
181
|
-
```ruby
|
182
|
-
def clear
|
183
|
-
messages.clear
|
184
|
-
details.clear
|
28
|
+
TraceLocation.trace do
|
29
|
+
# You just surround you want to track the process.
|
30
|
+
ActiveRecord::Base.establish_connection(config)
|
185
31
|
end
|
186
|
-
# called from activemodel-5.2.3/lib/active_model/validations.rb:338
|
187
32
|
```
|
188
33
|
|
189
|
-
|
190
|
-
<details open>
|
191
|
-
<summary>activemodel-5.2.3/lib/active_model/validations/callbacks.rb:117</summary>
|
34
|
+
Then you can get logs like this: [.md](https://github.com/yhirano55/trace_location/blob/master/examples/active_record_establish_connection/result.md), [.log](https://github.com/yhirano55/trace_location/blob/master/examples/active_record_establish_connection/result.log), [.csv](https://github.com/yhirano55/trace_location/blob/master/examples/active_record_establish_connection/result.csv)
|
192
35
|
|
193
|
-
|
194
|
-
```ruby
|
195
|
-
def run_validations!
|
196
|
-
_run_validation_callbacks { super }
|
197
|
-
end
|
198
|
-
# called from activemodel-5.2.3/lib/active_model/validations.rb:339
|
199
|
-
```
|
36
|
+
### Trace method options
|
200
37
|
|
201
|
-
|
202
|
-
|
203
|
-
|
38
|
+
| name | content | example |
|
39
|
+
|:-----|:--------|:--------|
|
40
|
+
| format | `:markdown`, `:log`, `:csv` (default: `:markdown`) | `:markdown` |
|
41
|
+
| match | Regexp for allow list | `/activerecord/` |
|
42
|
+
| ignore | Regexp for deny list | `/bootsnap\|activesupport/` |
|
204
43
|
|
205
|
-
|
206
|
-
```ruby
|
207
|
-
def run_validations!
|
208
|
-
_run_validate_callbacks
|
209
|
-
errors.empty?
|
210
|
-
end
|
211
|
-
# called from activemodel-5.2.3/lib/active_model/validations/callbacks.rb:118
|
212
|
-
```
|
44
|
+
## More examples
|
213
45
|
|
214
|
-
|
215
|
-
<details open>
|
216
|
-
<summary>activemodel-5.2.3/lib/active_model/validations.rb:303</summary>
|
46
|
+
### Example: Track the validation process of Active Record
|
217
47
|
|
218
|
-
##### ActiveModel::Validations#errors
|
219
48
|
```ruby
|
220
|
-
|
221
|
-
|
222
|
-
end
|
223
|
-
# called from activemodel-5.2.3/lib/active_model/validations.rb:410
|
49
|
+
book = Book.new(title: "My Book Title")
|
50
|
+
TraceLocation.trace(match: /activerecord/) { book.validate }
|
224
51
|
```
|
225
52
|
|
226
|
-
|
227
|
-
<details open>
|
228
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:209</summary>
|
53
|
+
Results: [.md](https://github.com/yhirano55/trace_location/blob/master/examples/active_record_validation_process/result.md), [.log](https://github.com/yhirano55/trace_location/blob/master/examples/active_record_validation_process/result.log), [.csv](https://github.com/yhirano55/trace_location/blob/master/examples/active_record_validation_process/result.csv)
|
229
54
|
|
230
|
-
|
231
|
-
```ruby
|
232
|
-
def empty?
|
233
|
-
size.zero?
|
234
|
-
end
|
235
|
-
# called from activemodel-5.2.3/lib/active_model/validations.rb:410
|
236
|
-
```
|
55
|
+
### Example: Track the lifecycle of Rails application
|
237
56
|
|
238
|
-
</details>
|
239
|
-
<details open>
|
240
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:179</summary>
|
241
|
-
|
242
|
-
##### ActiveModel::Errors#size
|
243
57
|
```ruby
|
244
|
-
|
245
|
-
values.flatten.size
|
246
|
-
end
|
247
|
-
# called from activemodel-5.2.3/lib/active_model/errors.rb:210
|
248
|
-
```
|
58
|
+
env = Rack::MockRequest.env_for('http://localhost:3000/books')
|
249
59
|
|
250
|
-
|
251
|
-
|
252
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:188</summary>
|
253
|
-
|
254
|
-
##### ActiveModel::Errors#values
|
255
|
-
```ruby
|
256
|
-
def values
|
257
|
-
messages.select do |key, value|
|
258
|
-
!value.empty?
|
259
|
-
end.values
|
60
|
+
TraceLocation.trace do
|
61
|
+
status, headers, body = Rails.application.call(env)
|
260
62
|
end
|
261
|
-
# called from activemodel-5.2.3/lib/active_model/errors.rb:180
|
262
63
|
```
|
263
64
|
|
264
|
-
|
265
|
-
<details open>
|
266
|
-
<summary>activemodel-5.2.3/lib/active_model/validations.rb:303</summary>
|
267
|
-
|
268
|
-
##### ActiveModel::Validations#errors
|
269
|
-
```ruby
|
270
|
-
def errors
|
271
|
-
@errors ||= Errors.new(self)
|
272
|
-
end
|
273
|
-
# called from activerecord-5.2.3/lib/active_record/validations.rb:68
|
274
|
-
```
|
65
|
+
Results: [.md](https://github.com/yhirano55/trace_location/blob/master/examples/lifecycle_of_rails_application/result.md), [.log](https://github.com/yhirano55/trace_location/blob/master/examples/lifecycle_of_rails_application/result.log), [.csv](https://github.com/yhirano55/trace_location/blob/master/examples/lifecycle_of_rails_application/result.csv)
|
275
66
|
|
276
|
-
|
277
|
-
<details open>
|
278
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:209</summary>
|
67
|
+
### Example: Track the `has_secure_password` in User model
|
279
68
|
|
280
|
-
##### ActiveModel::Errors#empty?
|
281
69
|
```ruby
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
70
|
+
class User < ApplicationRecord
|
71
|
+
# temporary surrounding with TraceLocation#trace
|
72
|
+
Trace.location(format: :markdown, ignore: /activesupport/) do
|
73
|
+
has_secure_password
|
74
|
+
end
|
286
75
|
```
|
287
76
|
|
288
|
-
|
289
|
-
<details open>
|
290
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:179</summary>
|
291
|
-
|
292
|
-
##### ActiveModel::Errors#size
|
293
|
-
```ruby
|
294
|
-
def size
|
295
|
-
values.flatten.size
|
296
|
-
end
|
297
|
-
# called from activemodel-5.2.3/lib/active_model/errors.rb:210
|
298
|
-
```
|
77
|
+
Results: [.md](https://github.com/yhirano55/trace_location/blob/master/examples/has_secure_password/result.md), [.log](https://github.com/yhirano55/trace_location/blob/master/examples/has_secure_password/result.log), [.csv](https://github.com/yhirano55/trace_location/blob/master/examples/has_secure_password/result.csv)
|
299
78
|
|
300
|
-
|
301
|
-
<details open>
|
302
|
-
<summary>activemodel-5.2.3/lib/active_model/errors.rb:188</summary>
|
79
|
+
### Example: Track the rendering process of action in controller class
|
303
80
|
|
304
|
-
##### ActiveModel::Errors#values
|
305
81
|
```ruby
|
306
|
-
|
307
|
-
|
308
|
-
!value.empty?
|
309
|
-
end.values
|
310
|
-
end
|
311
|
-
# called from activemodel-5.2.3/lib/active_model/errors.rb:180
|
312
|
-
```
|
313
|
-
|
314
|
-
</details>
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
### Example 02. Track the lifecycle of Rails application
|
82
|
+
class BooksController < ApplicationController
|
83
|
+
before_action :set_book, only: [:show, :update, :destroy]
|
319
84
|
|
85
|
+
# GET /books
|
86
|
+
def index
|
87
|
+
@books = Book.all
|
320
88
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
Created at /path/to/sampleapp/log/trace_location-2019050602051557077971.log
|
327
|
-
=> true
|
89
|
+
# temporary surrounding with TraceLocation#trace
|
90
|
+
TraceLocation.trace(format: :markdown, ignore: /activesupport|rbenv|concurrent-ruby/) do
|
91
|
+
render json: @books
|
92
|
+
end
|
93
|
+
end
|
328
94
|
```
|
329
95
|
|
330
|
-
|
331
|
-
|
332
|
-
```
|
333
|
-
Logged by TraceLocation gem at 2019-05-06 02:39:31 +0900
|
334
|
-
https://github.com/yhirano55/trace_location
|
335
|
-
|
336
|
-
[Tracing events] C: Call, R: Return
|
337
|
-
|
338
|
-
C railties-5.2.3/lib/rails.rb:39 [Rails.application]
|
339
|
-
R railties-5.2.3/lib/rails.rb:41 [Rails.application]
|
340
|
-
C railties-5.2.3/lib/rails/engine.rb:522 [Rails::Engine#call]
|
341
|
-
C railties-5.2.3/lib/rails/application.rb:607 [Rails::Application#build_request]
|
342
|
-
C railties-5.2.3/lib/rails/engine.rb:705 [Rails::Engine#build_request]
|
343
|
-
C railties-5.2.3/lib/rails/application.rb:247 [Rails::Application#env_config]
|
344
|
-
C railties-5.2.3/lib/rails/engine.rb:528 [Rails::Engine#env_config]
|
345
|
-
R railties-5.2.3/lib/rails/engine.rb:530 [Rails::Engine#env_config]
|
346
|
-
C railties-5.2.3/lib/rails/application.rb:372 [Rails::Application#config]
|
347
|
-
R railties-5.2.3/lib/rails/application.rb:374 [Rails::Application#config]
|
348
|
-
C railties-5.2.3/lib/rails/application.rb:372 [Rails::Application#config]
|
349
|
-
R railties-5.2.3/lib/rails/application.rb:374 [Rails::Application#config]
|
350
|
-
C railties-5.2.3/lib/rails/application.rb:394 [Rails::Application#secrets]
|
351
|
-
R railties-5.2.3/lib/rails/application.rb:414 [Rails::Application#secrets]
|
352
|
-
C activesupport-5.2.3/lib/active_support/ordered_options.rb:41 [ActiveSupport::OrderedOptions#method_missing]
|
353
|
-
C activesupport-5.2.3/lib/active_support/ordered_options.rb:37 [ActiveSupport::OrderedOptions#[]]
|
354
|
-
R activesupport-5.2.3/lib/active_support/ordered_options.rb:39 [ActiveSupport::OrderedOptions#[]]
|
355
|
-
R activesupport-5.2.3/lib/active_support/ordered_options.rb:54 [ActiveSupport::OrderedOptions#method_missing]
|
356
|
-
C railties-5.2.3/lib/rails/application.rb:428 [Rails::Application#secret_key_base]
|
357
|
-
C railties-5.2.3/lib/rails.rb:72 [Rails.env]
|
358
|
-
R railties-5.2.3/lib/rails.rb:74 [Rails.env]
|
359
|
-
C activesupport-5.2.3/lib/active_support/string_inquirer.rb:26 [ActiveSupport::StringInquirer#method_missing]
|
360
|
-
R activesupport-5.2.3/lib/active_support/string_inquirer.rb:32 [ActiveSupport::StringInquirer#method_missing]
|
361
|
-
C railties-5.2.3/lib/rails/application.rb:394 [Rails::Application#secrets]
|
362
|
-
R railties-5.2.3/lib/rails/application.rb:414 [Rails::Application#secrets]
|
363
|
-
C activesupport-5.2.3/lib/active_support/ordered_options.rb:41 [ActiveSupport::OrderedOptions#method_missing]
|
364
|
-
C activesupport-5.2.3/lib/active_support/ordered_options.rb:37 [ActiveSupport::OrderedOptions#[]]
|
365
|
-
R activesupport-5.2.3/lib/active_support/ordered_options.rb:39 [ActiveSupport::OrderedOptions#[]]
|
366
|
-
R activesupport-5.2.3/lib/active_support/ordered_options.rb:54 [ActiveSupport::OrderedOptions#method_missing]
|
367
|
-
R railties-5.2.3/lib/rails/application.rb:436 [Rails::Application#secret_key_base]
|
368
|
-
..................
|
369
|
-
(an omission)
|
370
|
-
..................
|
371
|
-
```
|
96
|
+
Results: [.md](https://github.com/yhirano55/trace_location/blob/master/examples/rendering_process/result.md), [.log](https://github.com/yhirano55/trace_location/blob/master/examples/rendering_process/result.log), [.csv](https://github.com/yhirano55/trace_location/blob/master/examples/rendering_process/result.csv)
|
372
97
|
|
373
98
|
## License
|
374
99
|
|