Class: AppMap::Tracer
- Inherits:
-
Object
- Object
- AppMap::Tracer
- Defined in:
- lib/appmap/trace.rb
Instance Method Summary collapse
-
#disable ⇒ Object
Private function.
- #enable ⇒ Object
- #enabled? ⇒ Boolean
-
#event? ⇒ Boolean
Whether there is an event available for processing.
-
#event_methods ⇒ Object
Gets a unique list of the methods that were invoked by the program.
-
#initialize ⇒ Tracer
constructor
Records the events which happen in a program.
-
#last_package_for_current_thread ⇒ Object
Gets the last package which was observed on the current thread.
-
#next_event ⇒ Object
Gets the next available event, if any.
-
#record_event(event, package: nil, defined_class: nil, method: nil) ⇒ Object
Record a program execution event.
-
#record_method(method) ⇒ Object
methodshould be duck-typed to respond to the following: * package * defined_class * name * static * comment * labels * source_location.
Constructor Details
#initialize ⇒ Tracer
Records the events which happen in a program.
85 86 87 88 89 90 |
# File 'lib/appmap/trace.rb', line 85 def initialize @events = [] @last_package_for_thread = {} @methods = Set.new @enabled = false end |
Instance Method Details
#disable ⇒ Object
Private function. Use AppMap.tracing#delete.
101 102 103 |
# File 'lib/appmap/trace.rb', line 101 def disable # :nodoc: @enabled = false end |
#enable ⇒ Object
92 93 94 |
# File 'lib/appmap/trace.rb', line 92 def enable @enabled = true end |
#enabled? ⇒ Boolean
96 97 98 |
# File 'lib/appmap/trace.rb', line 96 def enabled? @enabled end |
#event? ⇒ Boolean
Whether there is an event available for processing.
141 142 143 |
# File 'lib/appmap/trace.rb', line 141 def event? !@events.empty? end |
#event_methods ⇒ Object
Gets a unique list of the methods that were invoked by the program.
136 137 138 |
# File 'lib/appmap/trace.rb', line 136 def event_methods @methods.to_a end |
#last_package_for_current_thread ⇒ Object
Gets the last package which was observed on the current thread.
131 132 133 |
# File 'lib/appmap/trace.rb', line 131 def last_package_for_current_thread @last_package_for_thread[Thread.current.object_id] end |
#next_event ⇒ Object
Gets the next available event, if any.
146 147 148 |
# File 'lib/appmap/trace.rb', line 146 def next_event @events.shift end |
#record_event(event, package: nil, defined_class: nil, method: nil) ⇒ Object
Record a program execution event.
The event should be one of the MethodEvent subclasses.
108 109 110 111 112 113 114 115 116 |
# File 'lib/appmap/trace.rb', line 108 def record_event(event, package: nil, defined_class: nil, method: nil) return unless @enabled @last_package_for_thread[Thread.current.object_id] = package if package @events << event static = event.static if event.respond_to?(:static) @methods << Trace::RubyMethod.new(package, defined_class, method, static) \ if package && defined_class && method && (event.event == :call) end |
#record_method(method) ⇒ Object
method should be duck-typed to respond to the following:
-
package
-
defined_class
-
name
-
static
-
comment
-
labels
-
source_location
126 127 128 |
# File 'lib/appmap/trace.rb', line 126 def record_method(method) @methods << method end |