Class: AppMap::Command::Record

Inherits:
RecordStruct show all
Defined in:
lib/appmap/command/record.rb

Instance Attribute Summary

Attributes inherited from RecordStruct

#config, #program

Instance Method Summary collapse

Instance Method Details

#perform(&block) ⇒ Object



8
9
10
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
# File 'lib/appmap/command/record.rb', line 8

def perform(&block)
  tracer = AppMap.tracing.trace

  events = []
  quit = false
  event_thread = Thread.new do
    while tracer.event? || !quit
      event = tracer.next_event
      if event
        events << event.to_h
      else
        sleep 0.0001
      end
    end
  end
  event_thread.abort_on_exception = true

  at_exit do
    quit = true
    event_thread.join
    yield AppMap::APPMAP_FORMAT_VERSION,
          AppMap.,
          AppMap.class_map(tracer.event_methods),
          events
  end

  load program if program
end