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/rswag.rb,
lib/appmap/trace.rb,
lib/appmap/config.rb,
lib/appmap/handler.rb,
lib/appmap/railtie.rb,
lib/appmap/version.rb,
lib/appmap/cucumber.rb,
lib/appmap/hook_log.rb,
lib/appmap/metadata.rb,
lib/appmap/minitest.rb,
lib/appmap/node_cli.rb,
lib/appmap/class_map.rb,
lib/appmap/depends/api.rb,
lib/appmap/hook/method.rb,
lib/appmap/depends/util.rb,
lib/appmap/command/index.rb,
lib/appmap/command_error.rb,
lib/appmap/detect_enabled.rb,
lib/appmap/swagger/stable.rb,
lib/appmap/command/inspect.rb,
lib/appmap/service/guesser.rb,
lib/appmap/value_inspector.rb,
lib/appmap/depends/node_cli.rb,
lib/appmap/hook/method/ruby2.rb,
lib/appmap/hook/method/ruby3.rb,
lib/appmap/recording_methods.rb,
lib/appmap/depends/rake_tasks.rb,
lib/appmap/hook/record_around.rb,
lib/appmap/swagger/rake_tasks.rb,
lib/appmap/depends/test_runner.rb,
lib/appmap/handler/eval_handler.rb,
lib/appmap/depends/configuration.rb,
lib/appmap/handler/rails/context.rb,
lib/appmap/swagger/configuration.rb,
lib/appmap/handler/rails/template.rb,
lib/appmap/service/config_analyzer.rb,
lib/appmap/command/agent_setup/init.rb,
lib/appmap/handler/function_handler.rb,
lib/appmap/handler/net_http_handler.rb,
lib/appmap/handler/open_ssl_handler.rb,
lib/appmap/handler/rails/test_route.rb,
lib/appmap/handler/rails/sql_handler.rb,
lib/appmap/command/agent_setup/config.rb,
lib/appmap/command/agent_setup/status.rb,
lib/appmap/depends/test_file_inspector.rb,
lib/appmap/middleware/remote_recording.rb,
lib/appmap/service/validator/violation.rb,
lib/appmap/command/agent_setup/validate.rb,
lib/appmap/handler/marshal_load_handler.rb,
lib/appmap/handler/rails/render_handler.rb,
lib/appmap/handler/rails/request_handler.rb,
lib/appmap/service/test_command_provider.rb,
lib/appmap/swagger/markdown_descriptions.rb,
lib/appmap/service/test_framework_detector.rb,
lib/appmap/service/validator/config_validator.rb,
lib/appmap/service/integration_test_path_finder.rb,
ext/appmap/appmap.c
Overview
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ClassLength rubocop:disable Metrics/PerceivedComplexity rubocop:disable Style/Documentation rubocop:disable Layout/IndentationWidth
Defined Under Namespace
Modules: Command, Cucumber, Depends, Event, Handler, Metadata, Middleware, Minitest, ModuleMethods, ObjectMethods, RSpec, Rswag, Service, Swagger, Trace, Util, ValueInspector Classes: ClassMap, CommandError, Config, DetectEnabled, Hook, HookLog, NodeCLI, Open, OpenStruct, Railtie, StackPrinter, Tracer
Constant Summary collapse
- URL =
'https://github.com/applandinc/appmap-ruby'
- VERSION =
'1.1.1'
- APPMAP_FORMAT_VERSION =
'1.12.0'
- SUPPORTED_RUBY_VERSIONS =
%w[2.5 2.6 2.7 3.0 3.1 3.2 3.3].freeze
- DEFAULT_APPMAP_DIR =
'tmp/appmap'.freeze
- DEFAULT_CONFIG_FILE_PATH =
'appmap.yml'.freeze
- RECORDING_METHODS =
%i[rspec minitest cucumber remote requests].freeze
Class Method Summary collapse
- .caller_binding(level) ⇒ Object
-
.class_map(methods) ⇒ Object
Builds a class map from a config and a list of Ruby methods.
-
.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.
- .explain_queries? ⇒ Boolean
- .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.
- .output_dir ⇒ Object
- .parameter_schema? ⇒ Boolean
-
.record(thread: nil) ⇒ Object
Records the events which occur while processing a block, and returns an AppMap as a Hash.
- .recording_enabled?(recording_method = nil) ⇒ Boolean
-
.tracing ⇒ Object
Used to start tracing, stop tracing, and record events.
- .tracing_enabled?(thread: nil) ⇒ Boolean
Class Method Details
.caller_binding(level) ⇒ Object
105 106 107 108 109 |
# File 'ext/appmap/appmap.c', line 105
static VALUE
am_previous_bindings(VALUE self, VALUE level)
{
return rb_debug_inspector_open(bindings_callback, (void *) level);
}
|
.class_map(methods) ⇒ Object
Builds a class map from a config and a list of Ruby methods.
105 106 107 |
# File 'lib/appmap/agent.rb', line 105 def class_map(methods) ClassMap.build_from_methods(methods) end |
.configuration ⇒ Object
Gets the configuration. If there is no configuration, the default configuration is initialized.
21 22 23 |
# File 'lib/appmap/agent.rb', line 21 def configuration @configuration ||= initialize_configuration end |
.configuration=(config) ⇒ Object
Sets the configuration. This is only expected to happen once per Ruby process.
27 28 29 30 31 |
# File 'lib/appmap/agent.rb', line 27 def configuration=(config) warn "AppMap is already configured" if @configuration && config @configuration = config end |
.default_config_file_path ⇒ Object
37 38 39 |
# File 'lib/appmap/agent.rb', line 37 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.
111 112 113 114 |
# File 'lib/appmap/agent.rb', line 111 def @metadata ||= Metadata.detect.freeze Util.deep_dup(@metadata) end |
.explain_queries? ⇒ Boolean
120 121 122 |
# File 'lib/appmap/agent.rb', line 120 def explain_queries? ENV["APPMAP_EXPLAIN_QUERIES"] == "true" end |
.info(msg) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/appmap/agent.rb', line 57 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.
49 50 51 52 53 54 55 |
# File 'lib/appmap/agent.rb', line 49 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.
99 100 101 102 |
# File 'lib/appmap/agent.rb', line 99 def open(appmap = nil, &block) appmap ||= AppMap.record(&block) AppMap::Open.new(appmap).perform end |
.output_dir ⇒ Object
33 34 35 |
# File 'lib/appmap/agent.rb', line 33 def output_dir ENV["APPMAP_OUTPUT_DIR"] || DEFAULT_APPMAP_DIR end |
.parameter_schema? ⇒ Boolean
116 117 118 |
# File 'lib/appmap/agent.rb', line 116 def parameter_schema? ENV["APPMAP_PARAMETER_SCHEMA"] == "true" end |
.record(thread: nil) ⇒ Object
Records the events which occur while processing a block, and returns an AppMap as a Hash. Recording may optionally capture only a single thread.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/appmap/agent.rb', line 78 def record(thread: nil) tracer = tracing.trace(thread: thread) tracer.enable 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 |
.recording_enabled?(recording_method = nil) ⇒ Boolean
124 125 126 |
# File 'lib/appmap/agent.rb', line 124 def recording_enabled?(recording_method = nil) DetectEnabled.new(recording_method).enabled? 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 |
.tracing_enabled?(thread: nil) ⇒ Boolean
65 66 67 68 69 |
# File 'lib/appmap/agent.rb', line 65 def tracing_enabled?(thread: nil) return false unless @tracing @tracing.enabled?(thread_id: thread&.object_id) end |