Module: AppMap
- Defined in:
- lib/appmap/hook.rb,
lib/appmap/open.rb,
lib/appmap/util.rb,
lib/appmap/agent.rb,
lib/appmap/event.rb,
lib/appmap/rspec.rb,
lib/appmap/trace.rb,
lib/appmap/config.rb,
lib/appmap/railtie.rb,
lib/appmap/version.rb,
lib/appmap/cucumber.rb,
lib/appmap/metadata.rb,
lib/appmap/minitest.rb,
lib/appmap/node_cli.rb,
lib/appmap/class_map.rb,
lib/appmap/hook/method.rb,
lib/appmap/command_error.rb,
lib/appmap/swagger/stable.rb,
lib/appmap/command/inspect.rb,
lib/appmap/service/guesser.rb,
lib/appmap/handler/function.rb,
lib/appmap/handler/net_http.rb,
lib/appmap/swagger/rake_tasks.rb,
lib/appmap/swagger/configuration.rb,
lib/appmap/handler/rails/template.rb,
lib/appmap/command/agent_setup/init.rb,
lib/appmap/handler/rails/sql_handler.rb,
lib/appmap/middleware/remote_recording.rb,
lib/appmap/handler/rails/request_handler.rb,
lib/appmap/swagger/markdown_descriptions.rb,
ext/appmap/appmap.c
Defined Under Namespace
Modules: Command, Cucumber, Event, Handler, Metadata, Middleware, Minitest, RSpec, Service, Swagger, Trace, Util Classes: ClassMap, CommandError, Config, Hook, NodeCLI, Open, OpenStruct, Railtie, Tracer
Constant Summary collapse
- URL =
'https://github.com/applandinc/appmap-ruby'- VERSION =
'0.54.4'- APPMAP_FORMAT_VERSION =
'1.5.1'- DEFAULT_APPMAP_DIR =
'tmp/appmap'.freeze
- DEFAULT_CONFIG_FILE_PATH =
'appmap.yml'.freeze
Class Method Summary collapse
-
.class_map(methods) ⇒ Object
Builds a class map from a config and a list of Ruby methods.
- .config_message(msg) ⇒ Object
-
.configuration ⇒ Object
Gets the configuration.
-
.configuration=(config) ⇒ Object
Sets the configuration.
- .default_config_file_path ⇒ Object
-
.detect_metadata ⇒ Object
Returns default metadata detected from the Ruby system and from the filesystem.
- .info(msg) ⇒ Object
-
.initialize_configuration(config_file_path = default_config_file_path) ⇒ Object
Configures AppMap for recording.
-
.open(appmap = nil, &block) ⇒ Object
Uploads an AppMap to the AppLand website and displays it.
-
.record ⇒ Object
Records the events which occur while processing a block, and returns an AppMap as a Hash.
-
.tracing ⇒ Object
Used to start tracing, stop tracing, and record events.
Class Method Details
.class_map(methods) ⇒ Object
Builds a class map from a config and a list of Ruby methods.
104 105 106 |
# File 'lib/appmap/agent.rb', line 104 def class_map(methods) ClassMap.build_from_methods(methods) end |
.config_message(msg) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/appmap/agent.rb', line 60 def (msg) logger = if defined?(::Rails) && ::Rails.logger ::Rails.logger elsif ENV['DEBUG'] == 'true' method(:warn) else ->(msg) { } end logger.call(msg) end |
.configuration ⇒ Object
Gets the configuration. If there is no configuration, the default configuration is initialized.
20 21 22 |
# File 'lib/appmap/agent.rb', line 20 def configuration @configuration ||= initialize_configuration end |
.configuration=(config) ⇒ Object
Sets the configuration. This is only expected to happen once per Ruby process.
26 27 28 29 30 |
# File 'lib/appmap/agent.rb', line 26 def configuration=(config) warn 'AppMap is already configured' if @configuration && config @configuration = config end |
.default_config_file_path ⇒ Object
32 33 34 |
# File 'lib/appmap/agent.rb', line 32 def default_config_file_path ENV['APPMAP_CONFIG_FILE'] || 'appmap.yml' end |
.detect_metadata ⇒ Object
Returns default metadata detected from the Ruby system and from the filesystem.
110 111 112 113 |
# File 'lib/appmap/agent.rb', line 110 def ||= Metadata.detect.freeze Util.deep_dup() end |
.info(msg) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/appmap/agent.rb', line 52 def info(msg) if defined?(::Rails) && defined?(::Rails.logger) ::Rails.logger.info msg else warn msg end end |
.initialize_configuration(config_file_path = default_config_file_path) ⇒ Object
Configures AppMap for recording. Default behavior is to configure from APPMAP_CONFIG_FILE, or ‘appmap.yml’. If no config file is available, a configuration will be automatically generated and used - and the user is prompted to create the config file.
This method also activates 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.
44 45 46 47 48 49 50 |
# File 'lib/appmap/agent.rb', line 44 def initialize_configuration(config_file_path = default_config_file_path) Util. "Configuring AppMap from path #{config_file_path}" Config.load_from_file(config_file_path).tap do |configuration| self.configuration = configuration Hook.new(configuration).enable end end |
.open(appmap = nil, &block) ⇒ Object
Uploads an AppMap to the AppLand website and displays it.
98 99 100 101 |
# File 'lib/appmap/agent.rb', line 98 def open(appmap = nil, &block) appmap ||= AppMap.record(&block) AppMap::Open.new(appmap).perform end |
.record ⇒ Object
Records the events which occur while processing a block, and returns an AppMap as a Hash.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/appmap/agent.rb', line 78 def record tracer = tracing.trace begin yield ensure tracing.delete(tracer) end events = [].tap do |event_list| event_list << tracer.next_event.to_h while tracer.event? end { 'version' => AppMap::APPMAP_FORMAT_VERSION, 'metadata' => , 'classMap' => class_map(tracer.event_methods), 'events' => events } end |
.tracing ⇒ Object
Used to start tracing, stop tracing, and record events.
72 73 74 |
# File 'lib/appmap/agent.rb', line 72 def tracing @tracing ||= Trace::Tracing.new end |