appmap 0.39.0 → 0.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -16
- data/CHANGELOG.md +28 -2
- data/CONTRIBUTING.md +22 -0
- data/README.md +113 -51
- data/Rakefile +3 -3
- data/lib/appmap/class_map.rb +25 -8
- data/lib/appmap/config.rb +48 -28
- data/lib/appmap/event.rb +14 -4
- data/lib/appmap/hook.rb +18 -3
- data/lib/appmap/hook/method.rb +1 -1
- data/lib/appmap/rails/request_handler.rb +8 -3
- data/lib/appmap/railtie.rb +1 -5
- data/lib/appmap/version.rb +1 -1
- data/spec/abstract_controller_base_spec.rb +2 -2
- data/spec/config_spec.rb +1 -0
- data/spec/fixtures/hook/exclude.rb +15 -0
- data/spec/fixtures/hook/labels.rb +6 -0
- data/spec/fixtures/rails5_users_app/Gemfile +2 -3
- data/spec/fixtures/rails5_users_app/appmap.yml +4 -1
- data/spec/fixtures/rails5_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails5_users_app/docker-compose.yml +3 -0
- data/spec/fixtures/rails6_users_app/Gemfile +2 -3
- data/spec/fixtures/rails6_users_app/appmap.yml +4 -1
- data/spec/fixtures/rails6_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails6_users_app/docker-compose.yml +3 -0
- data/spec/hook_spec.rb +41 -41
- data/spec/record_sql_rails_pg_spec.rb +1 -1
- data/spec/rspec_feature_metadata_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/test/fixtures/gem_test/appmap.yml +1 -1
- data/test/fixtures/gem_test/test/parser_test.rb +12 -0
- data/test/gem_test.rb +4 -4
- metadata +6 -69
- data/spec/abstract_controller4_base_spec.rb +0 -66
- data/spec/fixtures/rails4_users_app/.gitignore +0 -13
- data/spec/fixtures/rails4_users_app/.rbenv-gemsets +0 -2
- data/spec/fixtures/rails4_users_app/.ruby-version +0 -1
- data/spec/fixtures/rails4_users_app/Dockerfile +0 -30
- data/spec/fixtures/rails4_users_app/Dockerfile.pg +0 -3
- data/spec/fixtures/rails4_users_app/Gemfile +0 -77
- data/spec/fixtures/rails4_users_app/README.rdoc +0 -28
- data/spec/fixtures/rails4_users_app/Rakefile +0 -6
- data/spec/fixtures/rails4_users_app/app/assets/images/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/assets/javascripts/application.js +0 -16
- data/spec/fixtures/rails4_users_app/app/assets/stylesheets/application.css +0 -15
- data/spec/fixtures/rails4_users_app/app/controllers/api/users_controller.rb +0 -27
- data/spec/fixtures/rails4_users_app/app/controllers/application_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/controllers/health_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/controllers/users_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/helpers/application_helper.rb +0 -2
- data/spec/fixtures/rails4_users_app/app/mailers/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/user.rb +0 -18
- data/spec/fixtures/rails4_users_app/app/views/layouts/application.html.haml +0 -7
- data/spec/fixtures/rails4_users_app/app/views/users/index.html.haml +0 -7
- data/spec/fixtures/rails4_users_app/appmap.yml +0 -3
- data/spec/fixtures/rails4_users_app/bin/rails +0 -9
- data/spec/fixtures/rails4_users_app/bin/setup +0 -29
- data/spec/fixtures/rails4_users_app/bin/spring +0 -17
- data/spec/fixtures/rails4_users_app/config.ru +0 -4
- data/spec/fixtures/rails4_users_app/config/application.rb +0 -26
- data/spec/fixtures/rails4_users_app/config/boot.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/database.yml +0 -18
- data/spec/fixtures/rails4_users_app/config/environment.rb +0 -5
- data/spec/fixtures/rails4_users_app/config/environments/development.rb +0 -41
- data/spec/fixtures/rails4_users_app/config/environments/production.rb +0 -79
- data/spec/fixtures/rails4_users_app/config/environments/test.rb +0 -42
- data/spec/fixtures/rails4_users_app/config/initializers/assets.rb +0 -11
- data/spec/fixtures/rails4_users_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/fixtures/rails4_users_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/fixtures/rails4_users_app/config/initializers/inflections.rb +0 -16
- data/spec/fixtures/rails4_users_app/config/initializers/mime_types.rb +0 -4
- data/spec/fixtures/rails4_users_app/config/initializers/session_store.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/fixtures/rails4_users_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/fixtures/rails4_users_app/config/locales/en.yml +0 -23
- data/spec/fixtures/rails4_users_app/config/routes.rb +0 -12
- data/spec/fixtures/rails4_users_app/config/secrets.yml +0 -22
- data/spec/fixtures/rails4_users_app/create_app +0 -23
- data/spec/fixtures/rails4_users_app/db/migrate/20191127112304_create_users.rb +0 -10
- data/spec/fixtures/rails4_users_app/db/schema.rb +0 -26
- data/spec/fixtures/rails4_users_app/db/seeds.rb +0 -7
- data/spec/fixtures/rails4_users_app/docker-compose.yml +0 -26
- data/spec/fixtures/rails4_users_app/lib/assets/.keep +0 -0
- data/spec/fixtures/rails4_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails4_users_app/log/.keep +0 -0
- data/spec/fixtures/rails4_users_app/public/404.html +0 -67
- data/spec/fixtures/rails4_users_app/public/422.html +0 -67
- data/spec/fixtures/rails4_users_app/public/500.html +0 -66
- data/spec/fixtures/rails4_users_app/public/favicon.ico +0 -0
- data/spec/fixtures/rails4_users_app/public/robots.txt +0 -5
- data/spec/fixtures/rails4_users_app/spec/controllers/users_controller_api_spec.rb +0 -49
- data/spec/fixtures/rails4_users_app/spec/rails_helper.rb +0 -95
- data/spec/fixtures/rails4_users_app/spec/spec_helper.rb +0 -96
- data/spec/fixtures/rails4_users_app/test/fixtures/users.yml +0 -9
- data/spec/record_sql_rails4_pg_spec.rb +0 -75
- data/test/fixtures/gem_test/test/to_param_test.rb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: adc97c5504b0171bfe253ae399f75ceabce09325656572f921520263023f3f8c
|
|
4
|
+
data.tar.gz: 35e0ca65e34c843ace959017ee2830e74d2f49878b8b0538f42ebde37855f6bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ee982724e27a8252a7506dda4ea9bf0817bd39f258d9d1ea01bd9b393aa3e523043ff2120e191806a6d41df096bfde110abf4956e4cd56ee1064aa12f4def9f
|
|
7
|
+
data.tar.gz: 715e4b8a140e8be61be375500a701ede6c01f0a709aee0cde0b65bd809a04b4c50543900ca9ac7bcbedd30f4252ef66ae9f18246eaa5591d3a9eeb7d5ba28be4
|
data/.travis.yml
CHANGED
|
@@ -16,22 +16,8 @@ before_script:
|
|
|
16
16
|
|
|
17
17
|
jobs:
|
|
18
18
|
include:
|
|
19
|
-
- stage:
|
|
19
|
+
- stage: test
|
|
20
20
|
script:
|
|
21
21
|
- mkdir tmp
|
|
22
|
-
- bundle exec rake
|
|
23
|
-
|
|
24
|
-
- stage: base
|
|
25
|
-
script:
|
|
26
|
-
- bundle exec rake build:base:2.5
|
|
27
|
-
- stage: base
|
|
28
|
-
script:
|
|
29
|
-
- bundle exec rake build:base:2.6
|
|
30
|
-
|
|
31
|
-
- stage: spec
|
|
32
|
-
script:
|
|
33
|
-
- bundle exec rake spec:2.5
|
|
34
|
-
- stage: spec
|
|
35
|
-
script:
|
|
36
|
-
- bundle exec rake spec:2.6
|
|
22
|
+
- bundle exec rake test
|
|
37
23
|
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
|
-
# v0.
|
|
1
|
+
# v0.41.2
|
|
2
|
+
|
|
3
|
+
* Don't rely on `gemspec.source_paths` to list all the source locations in a gem. Hook any code that's loaded
|
|
4
|
+
from inside the `gem_dir`.
|
|
5
|
+
|
|
6
|
+
# v0.41.1
|
|
7
|
+
|
|
8
|
+
* Make best effort to ensure that class name is not `null` in the appmap.json.
|
|
9
|
+
* Don't try and instrument gems which are a dependency of the this gem.
|
|
10
|
+
* Fix a nil exception when applying the exclude list to builtins.
|
|
11
|
+
|
|
12
|
+
# v0.41.0
|
|
13
|
+
|
|
14
|
+
* Adjust some label names to match `provider.*`, `format.*`.
|
|
15
|
+
* Add global `exclude` list to *appmap.yml* which can be used to definitively exclude specific classes and methods.
|
|
2
16
|
|
|
17
|
+
# v0.40.0
|
|
18
|
+
|
|
19
|
+
* Parse source code comments into function labels.
|
|
20
|
+
|
|
21
|
+
# v0.39.2
|
|
22
|
+
* Correctly recognize normalized path info for subengines.
|
|
23
|
+
|
|
24
|
+
# v0.39.1
|
|
25
|
+
* Support Ruby 2.7.
|
|
26
|
+
* Remove support for Rails 4.
|
|
27
|
+
* Stop recommending `-t appmap` argument for `rspec`.
|
|
28
|
+
|
|
29
|
+
# v0.39.0
|
|
3
30
|
* Recognize and record `normalized_path_info` in Rails applications, per 1.4 AppMap format version.
|
|
4
31
|
|
|
5
32
|
# v0.38.1
|
|
6
|
-
|
|
7
33
|
* Package configuration can be `shallow`, in case which only the initial entry into the package is recorded.
|
|
8
34
|
|
|
9
35
|
# v0.37.2
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Contributing to appmap-ruby
|
|
2
|
+
|
|
3
|
+
We are incredibly thankful for the contributions we receive from the community. Before contributing, please take a moment to read our [Contributor License Agreement](https://github.com/applandorg/community/blob/master/docs/CLA%20Instructions.pdf) and our [Code of Conduct](https://github.com/applandorg/community/blob/master/docs/Code%20of%20Conduct%20for%20Contributors.pdf).
|
|
4
|
+
|
|
5
|
+
## Contributor License Agreement
|
|
6
|
+
We require our external contributors to sign a Contributor License Agreement ("CLA") in order to ensure that
|
|
7
|
+
our projects remain licensed under Free and Open Source licenses such as while allowing
|
|
8
|
+
Appland to build a sustainable business.
|
|
9
|
+
|
|
10
|
+
AppLand is committed to having a true Free and Open Source Software license for our
|
|
11
|
+
non-commercial software. A CLA enables AppLand to safely commercialize our products while
|
|
12
|
+
keeping a standard FOSS license with all the rights that license grants to users.
|
|
13
|
+
|
|
14
|
+
* [Contributor License Agreement](https://github.com/applandorg/community/blob/master/docs/CLA%20Instructions.pdf)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Code of Conduct
|
|
18
|
+
|
|
19
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and
|
|
20
|
+
healthy community.
|
|
21
|
+
|
|
22
|
+
* [Code of Conduct](https://github.com/applandorg/community/blob/master/docs/Code%20of%20Conduct%20for%20Contributors.pdf)
|
data/README.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
- [About](#about)
|
|
3
|
+
- [Supported versions](#supported-versions)
|
|
3
4
|
- [Installation](#installation)
|
|
4
5
|
- [Configuration](#configuration)
|
|
6
|
+
- [Labels](#labels)
|
|
5
7
|
- [Running](#running)
|
|
6
8
|
- [RSpec](#rspec)
|
|
7
9
|
- [Minitest](#minitest)
|
|
8
10
|
- [Cucumber](#cucumber)
|
|
9
11
|
- [Remote recording](#remote-recording)
|
|
10
|
-
- [
|
|
12
|
+
- [Server process recording](#server-process-recording)
|
|
13
|
+
- [AppMap for VSCode](#appmap-for-vscode)
|
|
11
14
|
- [Uploading AppMaps](#uploading-appmaps)
|
|
12
15
|
- [Development](#development)
|
|
13
16
|
- [Running tests](#running-tests)
|
|
@@ -23,41 +26,51 @@
|
|
|
23
26
|
"AppMap" is a data format which records code structure (modules, classes, and methods), code execution events
|
|
24
27
|
(function calls and returns), and code metadata (repo name, repo URL, commit
|
|
25
28
|
SHA, labels, etc). It's more granular than a performance profile, but it's less
|
|
26
|
-
granular than a full debug trace. It's designed to be optimal for understanding the design intent and
|
|
29
|
+
granular than a full debug trace. It's designed to be optimal for understanding the design intent and structure of code and key data flows.
|
|
27
30
|
|
|
28
31
|
There are several ways to record AppMaps of your Ruby program using the `appmap` gem:
|
|
29
32
|
|
|
30
|
-
* Run your RSpec
|
|
33
|
+
* Run your tests (RSpec, Minitest, Cucumber) with the environment variable `APPMAP=true`. An AppMap will be generated for each spec.
|
|
31
34
|
* Run your application server with AppMap remote recording enabled, and use the [AppLand
|
|
32
35
|
browser extension](https://github.com/applandinc/appland-browser-extension) to start,
|
|
33
36
|
stop, and upload recordings.
|
|
34
|
-
*
|
|
37
|
+
* Wrap some code in an `AppMap.record` block, which returns JSON containing the code execution trace.
|
|
35
38
|
|
|
36
|
-
Once you have
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
Once you have made a recording, there are two ways to view automatically generated diagrams of the AppMaps.
|
|
40
|
+
|
|
41
|
+
The first option is to load the diagrams directly in your IDE, using the [AppMap extension for VSCode](https://marketplace.visualstudio.com/items?itemName=appland.appmap).
|
|
42
|
+
|
|
43
|
+
The second option is to upload them to the [AppLand server](https://app.land) using the [AppLand CLI](https://github.com/applandinc/appland-cli/releases).
|
|
44
|
+
|
|
45
|
+
### Supported versions
|
|
46
|
+
|
|
47
|
+
* Ruby 2.5, 2.6, 2.7
|
|
48
|
+
* Rails 5, 6
|
|
49
|
+
|
|
50
|
+
Support for new versions is added frequently, please check back regularly for updates.
|
|
41
51
|
|
|
42
52
|
# Installation
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
<a href="https://www.loom.com/share/78ab32a312ff4b85aa8827a37f1cb655"> <p>Quick and easy setup of the AppMap gem for Rails - Watch Video</p> <img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/78ab32a312ff4b85aa8827a37f1cb655-with-play.gif"> </a>
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
|
|
57
|
+
Add `gem 'appmap'` to **beginning** of your Gemfile. We recommend that you add the `appmap` gem to the `:development, :test` group. Your Gemfile should look something like this:
|
|
47
58
|
|
|
48
59
|
```
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
source 'https://rubygems.org'
|
|
61
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
# Optional rubRuby version
|
|
64
|
+
# ruby '2.7.2'
|
|
53
65
|
|
|
54
|
-
```
|
|
55
66
|
group :development, :test do
|
|
56
67
|
gem 'appmap'
|
|
57
68
|
end
|
|
58
69
|
```
|
|
59
70
|
|
|
60
|
-
|
|
71
|
+
Install with `bundle install`, as usual.
|
|
72
|
+
|
|
73
|
+
It's important to add the `appmap` gem before any other gems that you may want to instrument. There is more about this in the section on adding gems to the *appmap.yml*.
|
|
61
74
|
|
|
62
75
|
**Railtie**
|
|
63
76
|
|
|
@@ -65,7 +78,24 @@ If you are using Ruby on Rails, require the railtie after Rails is loaded.
|
|
|
65
78
|
|
|
66
79
|
```
|
|
67
80
|
# application.rb is a good place to do this, along with all the other railties.
|
|
68
|
-
require 'appmap
|
|
81
|
+
# Don't require the railtie in environments that don't bundle the appmap gem.
|
|
82
|
+
require 'appmap/railtie' if defined?(AppMap).
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**application.rb**
|
|
86
|
+
|
|
87
|
+
Add this line to *application.rb*, to enable server recording with `APPMAP_RECORD=true`:
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
module MyApp
|
|
91
|
+
class Application < Rails::Application
|
|
92
|
+
...
|
|
93
|
+
|
|
94
|
+
config.appmap.enabled = true if ENV['APPMAP_RECORD']
|
|
95
|
+
|
|
96
|
+
...
|
|
97
|
+
end
|
|
98
|
+
end
|
|
69
99
|
```
|
|
70
100
|
|
|
71
101
|
# Configuration
|
|
@@ -74,15 +104,28 @@ When you run your program, the `appmap` gem reads configuration settings from `a
|
|
|
74
104
|
file for a typical Rails project:
|
|
75
105
|
|
|
76
106
|
```yaml
|
|
77
|
-
name
|
|
107
|
+
# 'name' should generally be the same as the code repo name.
|
|
108
|
+
name: my_project
|
|
78
109
|
packages:
|
|
79
110
|
- path: app/controllers
|
|
80
111
|
- path: app/models
|
|
112
|
+
- path: app/jobs
|
|
113
|
+
- path: app/helpers
|
|
114
|
+
# Include the gems that you want to see in the dependency maps.
|
|
115
|
+
# These are just examples.
|
|
81
116
|
- gem: activerecord
|
|
117
|
+
- gem: devise
|
|
118
|
+
- gem: aws-sdk
|
|
119
|
+
- gem: will_paginate
|
|
120
|
+
exclude:
|
|
121
|
+
- MyClass
|
|
122
|
+
- MyClass#my_instance_method
|
|
123
|
+
- MyClass.my_class_method
|
|
82
124
|
```
|
|
83
125
|
|
|
84
126
|
* **name** Provides the project name (required)
|
|
85
|
-
* **packages** A list of source code directories which should be
|
|
127
|
+
* **packages** A list of source code directories which should be recorded.
|
|
128
|
+
* **exclude** A list of classes and/or methods to definitively exclude from recording.
|
|
86
129
|
|
|
87
130
|
**packages**
|
|
88
131
|
|
|
@@ -90,13 +133,46 @@ Each entry in the `packages` list is a YAML object which has the following keys:
|
|
|
90
133
|
|
|
91
134
|
* **path** The path to the source code directory. The path may be relative to the current working directory, or it may
|
|
92
135
|
be an absolute path.
|
|
93
|
-
* **gem** As an alternative to specifying the path, specify the name of a dependency gem. When using `gem`, don't specify `path`.
|
|
136
|
+
* **gem** As an alternative to specifying the path, specify the name of a dependency gem. When using `gem`, don't specify `path`. In your `Gemfile`, the `appmap` gem **must** be listed **before** any gem that you specify in your *appmap.yml*.
|
|
94
137
|
* **exclude** A list of files and directories which will be ignored. By default, all modules, classes and public
|
|
95
|
-
functions are inspected.
|
|
138
|
+
functions are inspected. See also: global `exclude` list.
|
|
96
139
|
* **shallow** When set to `true`, only the first function call entry into a package will be recorded. Subsequent function calls within
|
|
97
140
|
the same package are not recorded unless code execution leaves the package and re-enters it. Default: `true` when using `gem`,
|
|
98
141
|
`false` when using `path`.
|
|
99
142
|
|
|
143
|
+
**exclude**
|
|
144
|
+
|
|
145
|
+
Optional list of fully qualified class and method names. Separate class and method names with period (`.`) for class methods and hash (`#`) for instance methods.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# Labels
|
|
149
|
+
|
|
150
|
+
The [AppMap data format](https://github.com/applandinc/appmap) provides for class and function `labels`, which can be used to enhance the AppMap visualizations, and to programatically analyze the data.
|
|
151
|
+
|
|
152
|
+
You can apply function labels using source code comments in your Ruby code. To apply a labels to a function, add a `@label` or `@labels` line to the comment which immediately precedes a function.
|
|
153
|
+
|
|
154
|
+
For example, if you add this comment to your source code:
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
class ApiKey
|
|
158
|
+
# @labels provider.authentication security
|
|
159
|
+
def authenticate(key)
|
|
160
|
+
# logic to verify the key here...
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Then the AppMap metadata section for this function will include:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"name": "authenticate",
|
|
170
|
+
"type": "function",
|
|
171
|
+
"labels": [ "provider.authentication", "security" ]
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
|
|
100
176
|
# Running
|
|
101
177
|
|
|
102
178
|
## RSpec
|
|
@@ -122,13 +198,10 @@ require 'appmap/rspec'
|
|
|
122
198
|
require File.expand_path("../../config/environment", __FILE__)
|
|
123
199
|
```
|
|
124
200
|
|
|
125
|
-
2)
|
|
126
|
-
examples.
|
|
127
|
-
|
|
128
|
-
3) Run the tests with the environment variable `APPMAP=true`:
|
|
201
|
+
2) Run the tests with the environment variable `APPMAP=true`:
|
|
129
202
|
|
|
130
203
|
```sh-session
|
|
131
|
-
$ APPMAP=true bundle exec rspec
|
|
204
|
+
$ APPMAP=true bundle exec rspec
|
|
132
205
|
```
|
|
133
206
|
|
|
134
207
|
Each RSpec test will output an AppMap file into the directory `tmp/appmap/rspec`. For example:
|
|
@@ -138,23 +211,6 @@ $ find tmp/appmap/rspec
|
|
|
138
211
|
Hello_says_hello_when_prompted.appmap.json
|
|
139
212
|
```
|
|
140
213
|
|
|
141
|
-
If you include the `feature` and `feature_group` metadata, these attributes will be exported to the AppMap file in the
|
|
142
|
-
`metadata` section. It will look something like this:
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
{
|
|
146
|
-
...
|
|
147
|
-
"metadata": {
|
|
148
|
-
"name": "Hello app says hello when prompted",
|
|
149
|
-
"feature": "Hello app says hello",
|
|
150
|
-
"feature_group": "Hello"
|
|
151
|
-
},
|
|
152
|
-
...
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
If you don't explicitly declare `feature` and `feature_group`, then they will be inferred from the spec name and example descriptions.
|
|
157
|
-
|
|
158
214
|
## Minitest
|
|
159
215
|
|
|
160
216
|
To record Minitest tests, follow these additional steps:
|
|
@@ -181,13 +237,13 @@ require_relative '../config/environment'
|
|
|
181
237
|
2) Run your tests as you normally would with the environment variable `APPMAP=true`. For example:
|
|
182
238
|
|
|
183
239
|
```
|
|
184
|
-
$ APPMAP=true bundle exec rake
|
|
240
|
+
$ APPMAP=true bundle exec rake test
|
|
185
241
|
```
|
|
186
242
|
|
|
187
243
|
or
|
|
188
244
|
|
|
189
245
|
```
|
|
190
|
-
$ APPMAP=true bundle exec -Ilib -Itest test/*
|
|
246
|
+
$ APPMAP=true bundle exec ruby -Ilib -Itest test/*_test.rb
|
|
191
247
|
```
|
|
192
248
|
|
|
193
249
|
Each Minitest test will output an AppMap file into the directory `tmp/appmap/minitest`. For example:
|
|
@@ -244,9 +300,9 @@ To manually record ad-hoc AppMaps of your Ruby app, use AppMap remote recording.
|
|
|
244
300
|
1. Add the AppMap remote recording middleware. For example, in `config/initializers/appmap_remote_recording.rb`:
|
|
245
301
|
|
|
246
302
|
```ruby
|
|
247
|
-
|
|
303
|
+
if defined?(AppMap)
|
|
304
|
+
require 'appmap/middleware/remote_recording'
|
|
248
305
|
|
|
249
|
-
unless Rails.env.test?
|
|
250
306
|
Rails.application.config.middleware.insert_after \
|
|
251
307
|
Rails::Rack::Logger,
|
|
252
308
|
AppMap::Middleware::RemoteRecording
|
|
@@ -267,18 +323,24 @@ $ bundle exec rails server
|
|
|
267
323
|
|
|
268
324
|
6. Open the AppLand browser extension and push `Stop`. The recording will be transferred to the AppLand website and opened in your browser.
|
|
269
325
|
|
|
270
|
-
##
|
|
326
|
+
## Server process recording
|
|
327
|
+
|
|
328
|
+
Run your Rails server with `APPMAP_RECORD=true`. When the server exits, an *appmap.json* file will be written to the project directory. This is a great way to start the server, interact with your app as a user (or through it's API), and then view an AppMap of everything that happened.
|
|
271
329
|
|
|
272
|
-
|
|
330
|
+
Be sure and set `WEB_CONCURRENCY=1`, if you are using a webserver that can run multiple processes. You only want there to be one process while you are recording, otherwise they will both try and write *appmap.json* and one of them will clobber the other.
|
|
273
331
|
|
|
274
|
-
|
|
332
|
+
# AppMap for VSCode
|
|
333
|
+
|
|
334
|
+
The [AppMap extension for VSCode](https://marketplace.visualstudio.com/items?itemName=appland.appmap) is a great way to onboard developers to new code, and troubleshoot hard-to-understand bugs with visuals.
|
|
275
335
|
|
|
276
336
|
# Uploading AppMaps
|
|
277
337
|
|
|
338
|
+
[https://app.land](https://app.land) can be used to store, analyze, and share AppMaps.
|
|
339
|
+
|
|
278
340
|
For instructions on uploading, see the documentation of the [AppLand CLI](https://github.com/applandinc/appland-cli).
|
|
279
341
|
|
|
280
342
|
# Development
|
|
281
|
-
[](https://travis-ci.com/applandinc/appmap-ruby)
|
|
282
344
|
|
|
283
345
|
## Running tests
|
|
284
346
|
|
data/Rakefile
CHANGED
|
@@ -18,12 +18,12 @@ namespace 'gem' do
|
|
|
18
18
|
require 'bundler/gem_tasks'
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
RUBY_VERSIONS=%w[2.5 2.6]
|
|
22
|
-
FIXTURE_APPS=%w[rack_users_app rails6_users_app rails5_users_app
|
|
21
|
+
RUBY_VERSIONS=%w[2.5 2.6 2.7]
|
|
22
|
+
FIXTURE_APPS=%w[rack_users_app rails6_users_app rails5_users_app]
|
|
23
23
|
|
|
24
24
|
def run_cmd(*cmd)
|
|
25
25
|
$stderr.puts "Running: #{cmd}"
|
|
26
|
-
out,s = Open3.capture2e(*cmd)
|
|
26
|
+
out, s = Open3.capture2e(*cmd)
|
|
27
27
|
unless s.success?
|
|
28
28
|
$stderr.puts <<-END
|
|
29
29
|
Command failed:
|
data/lib/appmap/class_map.rb
CHANGED
|
@@ -113,17 +113,18 @@ module AppMap
|
|
|
113
113
|
[ method.defined_class, static ? '.' : '#', method.name ].join
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
source, comment = begin
|
|
117
|
+
[ method.source, method.comment ]
|
|
118
|
+
rescue MethodSource::SourceNotFoundError
|
|
119
|
+
[ nil, nil, ]
|
|
120
|
+
end
|
|
121
|
+
|
|
116
122
|
if include_source
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
comment = method.comment || ''
|
|
120
|
-
function_info[:comment] = comment unless comment.empty?
|
|
121
|
-
rescue MethodSource::SourceNotFoundError
|
|
122
|
-
# pass
|
|
123
|
-
end
|
|
123
|
+
function_info[:source] = source unless source.blank?
|
|
124
|
+
function_info[:comment] = comment unless comment.blank?
|
|
124
125
|
end
|
|
125
126
|
|
|
126
|
-
function_info[:labels] = package.labels
|
|
127
|
+
function_info[:labels] = parse_labels(comment) + (package.labels || [])
|
|
127
128
|
object_infos << function_info
|
|
128
129
|
|
|
129
130
|
parent = root
|
|
@@ -141,6 +142,22 @@ module AppMap
|
|
|
141
142
|
end
|
|
142
143
|
end
|
|
143
144
|
|
|
145
|
+
# Labels can be embedded in the function comment. Label format is similar to YARD and JavaDoc.
|
|
146
|
+
# The keyword is @labels or @label. The keyword is followed by space-separated labels.
|
|
147
|
+
# For example:
|
|
148
|
+
# @label provider.authentication security
|
|
149
|
+
def parse_labels(comment)
|
|
150
|
+
return [] unless comment
|
|
151
|
+
|
|
152
|
+
comment
|
|
153
|
+
.split("\n")
|
|
154
|
+
.map { |line| line.match(/^\s*#\s*@labels?\s+(.*)/) }
|
|
155
|
+
.compact
|
|
156
|
+
.map { |match| match[1] }
|
|
157
|
+
.inject([]) { |accum, labels| accum += labels.split(/\s+/); accum }
|
|
158
|
+
.sort
|
|
159
|
+
end
|
|
160
|
+
|
|
144
161
|
def find_or_create(list, info)
|
|
145
162
|
obj = list.find { |item| item.type == info[:type] && item.name == info[:name] }
|
|
146
163
|
return obj if obj
|