Class: Rookout::Services::Tracer
- Inherits:
-
Object
- Object
- Rookout::Services::Tracer
- Defined in:
- lib/rookout/services/tracer.rb
Instance Method Summary collapse
- #add_breakpoint_aug(positions, aug) ⇒ Object
- #clear_augs ⇒ Object
- #close ⇒ Object
-
#initialize ⇒ Tracer
constructor
A new instance of Tracer.
- #remove_aug(aug_id) ⇒ Object
Constructor Details
#initialize ⇒ Tracer
Returns a new instance of Tracer.
6 7 8 9 |
# File 'lib/rookout/services/tracer.rb', line 6 def initialize @trace_points = {} @augs = {} end |
Instance Method Details
#add_breakpoint_aug(positions, aug) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rookout/services/tracer.rb', line 11 def add_breakpoint_aug positions, aug return if @augs.include? aug.id aug_trace_points = [] positions.each do |position| trace_point = create_trace_point aug begin trace_point.enable target: position.method, target_line: position.lineno rescue RuntimeError, ArgumentError => e trace_point.disable # just to make sure if something was partially added to clear everything if e..include? "can not enable any hooks" raise Exceptions::RookInvalidPositionException.new(aug.filename, position.lineno) end raise Exceptions::RookSetTracepointFailed.new(position.lineno, e) ensure # We add and remove a dummy trace point to re-align the tracing mechanism as a result of some bug in adding # a breakpoint https://bugs.ruby-lang.org/issues/17302 begin dummy_trace_point = TracePoint.new(:line) {} # Dummy dummy_trace_point.enable target: position.method, target_line: position.lineno dummy_trace_point.disable rescue # IGNORE end end aug_trace_points.push trace_point end @trace_points[aug.id] = aug_trace_points @augs[aug.id] = aug aug.notify_active end |
#clear_augs ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/rookout/services/tracer.rb', line 58 def clear_augs @augs.each_value do |aug_id| remove_aug aug_id end @trace_points = {} @augs = {} end |
#close ⇒ Object
67 68 69 |
# File 'lib/rookout/services/tracer.rb', line 67 def close clear_augs end |
#remove_aug(aug_id) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rookout/services/tracer.rb', line 44 def remove_aug aug_id aug = @augs[aug_id] return if aug.nil? aug_trace_points = @trace_points[aug_id] unless aug_trace_points.nil? aug_trace_points.each(&:disable) end @augs.delete aug_id @trace_points.delete aug_id aug.notify_removed end |