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.
87 88 89 90 91 92 |
# File 'lib/appmap/trace.rb', line 87 def initialize @events = [] @last_package_for_thread = {} @methods = Set.new @enabled = false end |
Instance Method Details
#disable ⇒ Object
Private function. Use AppMap.tracing#delete.
103 104 105 |
# File 'lib/appmap/trace.rb', line 103 def disable # :nodoc: @enabled = false end |
#enable ⇒ Object
94 95 96 |
# File 'lib/appmap/trace.rb', line 94 def enable @enabled = true end |
#enabled? ⇒ Boolean
98 99 100 |
# File 'lib/appmap/trace.rb', line 98 def enabled? @enabled end |
#event? ⇒ Boolean
Whether there is an event available for processing.
143 144 145 |
# File 'lib/appmap/trace.rb', line 143 def event? !@events.empty? end |
#event_methods ⇒ Object
Gets a unique list of the methods that were invoked by the program.
138 139 140 |
# File 'lib/appmap/trace.rb', line 138 def event_methods @methods.to_a end |
#last_package_for_current_thread ⇒ Object
Gets the last package which was observed on the current thread.
133 134 135 |
# File 'lib/appmap/trace.rb', line 133 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.
148 149 150 |
# File 'lib/appmap/trace.rb', line 148 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.
110 111 112 113 114 115 116 117 118 |
# File 'lib/appmap/trace.rb', line 110 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) record_method 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
128 129 130 |
# File 'lib/appmap/trace.rb', line 128 def record_method(method) @methods << method end |