Sha256: 0833b215936e2753815efb4bba7adc3420a1c1fec9b18246d9066a10a0ac4d50

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

module AppMap
  module Command
    RecordStruct = Struct.new(:config, :program)

    class Record < RecordStruct
      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.detect_metadata,
                AppMap.class_map(tracer.event_methods, include_source: AppMap.include_source?),
                events
        end

        load program if program
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appmap-0.43.0 lib/appmap/command/record.rb
appmap-0.42.1 lib/appmap/command/record.rb
appmap-0.42.0 lib/appmap/command/record.rb