Class: AppMap::Command::Record

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

Instance Attribute Summary

Attributes inherited from RecordStruct

#config, #program

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.detect_metadataObject

Builds a Hash of metadata which can be detected by inspecting the system.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/appmap/command/record.rb', line 10

def 
  {
    language: {
      name: 'ruby',
      engine: RUBY_ENGINE,
      version: RUBY_VERSION
    },
    client: {
      name: 'appmap',
      url: AppMap::URL,
      version: AppMap::VERSION
    }
  }.tap do |m|
    if defined?(::Rails)
      m[:frameworks] ||= []
      m[:frameworks] << {
        name: 'rails',
        version: ::Rails.version
      }
    end
    m[:git] =  if git_available
  end
end

Instance Method Details

#perform(&block) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/appmap/command/record.rb', line 65

def perform(&block)
  AppMap::Hook.hook(config)

  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,
          self.class.,
          AppMap.class_map(config, tracer.event_methods),
          events
  end

  load program if program
end