Module: AppMap

Defined in:
lib/appmap.rb,
lib/appmap/hook.rb,
lib/appmap/event.rb,
lib/appmap/rspec.rb,
lib/appmap/trace.rb,
lib/appmap/railtie.rb,
lib/appmap/version.rb,
lib/appmap/class_map.rb,
lib/appmap/command/stats.rb,
lib/appmap/command/record.rb,
lib/appmap/algorithm/stats.rb,
lib/appmap/rails/sql_handler.rb,
lib/appmap/rails/action_handler.rb,
lib/appmap/algorithm/prune_class_map.rb,
lib/appmap/middleware/remote_recording.rb

Defined Under Namespace

Modules: Algorithm, Command, Event, Middleware, RSpec, Rails, Trace Classes: ClassMap, Hook, Railtie, Tracer

Constant Summary collapse

BATCH_HEADER_NAME =
'AppLand-Scenario-Batch'
URL =
'https://github.com/applandinc/appmap-ruby'
VERSION =
'0.26.1'
APPMAP_FORMAT_VERSION =
'1.2'

Class Method Summary collapse

Class Method Details

.class_map(config, methods) ⇒ Object

Build a class map from a config and a list of Ruby methods.



60
61
62
63
# File 'lib/appmap.rb', line 60

def class_map(config, methods)
  require 'appmap/class_map'
  AppMap::ClassMap.build_from_methods(config, methods)
end

.configurationObject

configuration gets the AppMap configuration.



20
21
22
23
24
# File 'lib/appmap.rb', line 20

def configuration
  raise "AppMap is not configured" unless @config

  @config
end

.configure(config_file_path = 'appmap.yml') ⇒ Object

configure applies the configuration from a file. This method can only be performed once. Be sure and call it before hook if you want non-default configuration.

Default behavior is to configure from “appmap.yml”.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/appmap.rb', line 30

def configure(config_file_path = 'appmap.yml')
  if @config
    return @config if @config_file_path == config_file_path

    raise "AppMap is already configured from #{@config_file_path}, can't reconfigure from #{config_file_path}"
  end

  warn "Configuring AppMap from path #{config_file_path}"
  require 'appmap/hook'
  AppMap::Hook::Config.load_from_file(config_file_path).tap do |config|
    @config = config
    @config_file_path = config_file_path
  end
end

.hook(config = configure) ⇒ Object

Activate the code hooks which record function calls as trace events. Call this function before the program code is loaded by the Ruby VM, otherwise the load events won’t be seen and the hooks won’t activate.



48
49
50
51
# File 'lib/appmap.rb', line 48

def hook(config = configure)
  require 'appmap/hook'
  AppMap::Hook.hook(config)
end

.tracingObject

Access the AppMap::Tracers, which can be used to start tracing, stop tracing, and record events.



54
55
56
57
# File 'lib/appmap.rb', line 54

def tracing
  require 'appmap/trace'
  @tracing ||= Trace::Tracers.new
end