chaos_detector 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chaos_detector/tracker.rb +36 -13
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24cde9a6bfd85b11befa0042ad354fbe0ab279c45b85d86540f9a3f7524cc3b4
4
- data.tar.gz: 2f491ab3c05ee1b61c80c0a42491d50d2416d5bba28dfb7d956cebe0c52308c6
3
+ metadata.gz: a1a48c248ec02d045966d0e5ed5fafdab7c59989a9949c36b2757d571fa04e3e
4
+ data.tar.gz: cb67f69b6f8c7d1a6c07563e89a8d9b153c8b5c5b9ce8745b0830e898b7ad618
5
5
  SHA512:
6
- metadata.gz: 8f0e024db29ece9b9dd7d5d7f58fdcdc7a24745738b55216e52d44bf436b8eef77df3f95521b59ed3d217e32a0c75311543769100687764fa4d39fbbdbf9b3aa
7
- data.tar.gz: e73b6b4d4ee2887e232b75290a7c09286713370d30f0d5b8e4343a06a36da4bd5234ef866dab7bdec3293638a3aa010720b767905d8b30682891b8f0b3dfb5d1
6
+ metadata.gz: 60a4d7e0c3cac8956c4eed8323917d51f8fc209bddcf5d14b4ac79af9e30e4cf6a9d05239821ac56518750e82c75cb6485c12a019c3eb831329a35f341171ac6
7
+ data.tar.gz: e6dcb825c4cfe0bef110c175fb0ee0d54e7180a3d8968cf44a4fdda7ac7a96345ef097114d4364240853facc430924aa4947fb5184322aa2f105a11e2a12c576
@@ -45,19 +45,39 @@ module ChaosDetector
45
45
  tp_path = tracepoint.path
46
46
  next if full_path_skip?(tp_path)
47
47
 
48
+ # puts("Tracepoint: #{tracepoint.inspect}")
49
+ # log_mod_details(tracepoint)
50
+
48
51
  tp_class = tracepoint.defined_class
52
+ tp_event = tracepoint.event
53
+
54
+ fn_name = tracepoint.callee_id.to_s
55
+ fn_line = tracepoint.lineno
56
+ fn_path = localize_path(tp_path)
57
+ binding_info = tracepoint.self.send(:class)&.name
58
+ caller_locations = tracepoint.self.send(:caller_locations)
49
59
 
50
60
  # trace_mod_details(tracepoint)
51
- mod_info = mod_info_at(tp_class, mod_full_path: tp_path)
52
- # puts "mod_info: #{mod_info} #{tp_class.respond_to?(:superclass) && tp_class.superclass}"
53
- next unless mod_info
61
+ tracepoint.disable do
62
+ mod_info = mod_info_at(tp_class, mod_full_path: tp_path)
63
+ # puts "mod_info: #{mod_info} #{tp_class.respond_to?(:superclass) && tp_class.superclass}"
64
+ next unless mod_info
54
65
 
55
- fn_info = fn_info_at(tracepoint)
56
- e = tracepoint.event
57
- @trace.disable do
58
66
  @total_traces += 1
59
- caller_info = extract_caller(tracepoint, fn_info)
60
- write_event_frame(e, fn_info: fn_info, mod_info: mod_info, caller_info: caller_info)
67
+ fn_info = fn_info_at(fn_name, fn_line: fn_line, fn_path: fn_path)
68
+ caller_info = extract_caller(caller_locations: caller_locations, fn_info: fn_info)
69
+ write_event_frame(tp_event, fn_info: fn_info, mod_info: mod_info, caller_info: caller_info)
70
+
71
+ if tp_event==:call
72
+ puts('<' * 50)
73
+ puts("Binding: #{binding_info}")
74
+ puts("Module: #{mod_info}")
75
+ puts("Function: #{fn_info}")
76
+ puts("Caller: #{caller_info.inspect}") if caller_info
77
+ puts('>' * 50)
78
+ puts
79
+ end
80
+
61
81
 
62
82
  # Detect superclass association:
63
83
  ChaosUtils.with(superclass_mod_info(tp_class)) do |super_mod_info|
@@ -139,9 +159,8 @@ module ChaosDetector
139
159
  @app_root_path = ChaosUtils.with(@options.app_root_path) { |p| Pathname.new(p)&.to_s}
140
160
  end
141
161
 
142
- def extract_caller(tracepoint, fn_info)
143
- callers = tracepoint.self.send(:caller_locations)
144
- callers = callers.select do |bt|
162
+ def extract_caller(caller_locations:, fn_info:)
163
+ callers = caller_locations.select do |bt|
145
164
  !full_path_skip?(bt.absolute_path) &&
146
165
  ChaosUtils.aught?(bt.base_label) &&
147
166
  !bt.base_label.start_with?('<')
@@ -195,8 +214,12 @@ module ChaosDetector
195
214
  end
196
215
  end
197
216
 
198
- def fn_info_at(tracepoint)
199
- ChaosDetector::Stacker::FnInfo.new(fn_name: tracepoint.callee_id.to_s, fn_line: tracepoint.lineno, fn_path: localize_path(tracepoint.path))
217
+ def fn_info_at(fn_name, fn_line:, fn_path:)
218
+ ChaosDetector::Stacker::FnInfo.new(
219
+ fn_name: fn_name,
220
+ fn_line: fn_line,
221
+ fn_path: fn_path,
222
+ )
200
223
  end
201
224
 
202
225
  # TODO: MAKE more LIKE module_skip below:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chaos_detector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Miers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2020-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -80,7 +80,8 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.20.3
83
- description: Discover and graph dependencies for ruby and RoR apps
83
+ description: Infer and discover and graph dependencies for ruby and RoR apps during
84
+ EXECUTION
84
85
  email: steven.miers@gmail.com
85
86
  executables:
86
87
  - detect_chaos