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.



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

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



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

def perform(&block)
  features = AppMap.inspect(config)
  functions = features.map(&:collect_functions).flatten

  require 'appmap/trace/tracer'

  tracer = AppMap::Trace.tracers.trace(functions)

  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 features, events
  end

  load program if program
end