@appland/appmap 3.133.0 → 3.134.0

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/built/cmds/index/index.js +3 -3
  3. package/built/cmds/index/index.js.map +1 -1
  4. package/built/cmds/index/rpc.js +18 -7
  5. package/built/cmds/index/rpc.js.map +1 -1
  6. package/built/cmds/navie/help.js +122 -0
  7. package/built/cmds/navie/help.js.map +1 -0
  8. package/built/docs/CLA Instructions.pdf +0 -0
  9. package/built/docs/Code of Conduct for Contributors.pdf +0 -0
  10. package/built/docs/analysis/rules-reference.html +27 -0
  11. package/built/docs/appmap-overview.md +54 -0
  12. package/built/docs/community.md +27 -0
  13. package/built/docs/diagrams/dependency-map.md +63 -0
  14. package/built/docs/diagrams/flamegraph.md +91 -0
  15. package/built/docs/diagrams/how-it-works.md +60 -0
  16. package/built/docs/diagrams/index.md +20 -0
  17. package/built/docs/diagrams/sequence-diagram.md +75 -0
  18. package/built/docs/diagrams/trace-view.md +55 -0
  19. package/built/docs/guides/configuring-analysis.md +157 -0
  20. package/built/docs/guides/handling-large-appmaps.md +43 -0
  21. package/built/docs/guides/index.md +17 -0
  22. package/built/docs/guides/openapi.md +104 -0
  23. package/built/docs/guides/reading-sql-in-appmaps.md +67 -0
  24. package/built/docs/guides/refine-appmaps.md +186 -0
  25. package/built/docs/guides/reverse-engineering.md +375 -0
  26. package/built/docs/guides/runtime-code-review.md +108 -0
  27. package/built/docs/integrations/atlassian-compass.md +24 -0
  28. package/built/docs/integrations/atlassian-confluence.md +50 -0
  29. package/built/docs/integrations/docker.md +108 -0
  30. package/built/docs/integrations/github-actions.md +24 -0
  31. package/built/docs/integrations/index.md +17 -0
  32. package/built/docs/integrations/plantuml.md +65 -0
  33. package/built/docs/integrations/postman.md +29 -0
  34. package/built/docs/integrations/readme.md +38 -0
  35. package/built/docs/integrations/smartbear-swaggerhub.md +125 -0
  36. package/built/docs/navie/bring-your-own-key.md +98 -0
  37. package/built/docs/navie/demo.md +49 -0
  38. package/built/docs/navie/how-navie-works.md +26 -0
  39. package/built/docs/navie/how-to-use-navie.md +152 -0
  40. package/built/docs/navie/index.md +20 -0
  41. package/built/docs/reference/analysis-labels.md +48 -0
  42. package/built/docs/reference/analysis-rules.md +60 -0
  43. package/built/docs/reference/appmap-agent-js.md +215 -0
  44. package/built/docs/reference/appmap-client-cli.md +527 -0
  45. package/built/docs/reference/appmap-gradle-plugin.md +140 -0
  46. package/built/docs/reference/appmap-java.md +310 -0
  47. package/built/docs/reference/appmap-maven-plugin.md +163 -0
  48. package/built/docs/reference/appmap-node.md +185 -0
  49. package/built/docs/reference/appmap-python.md +395 -0
  50. package/built/docs/reference/appmap-ruby.md +514 -0
  51. package/built/docs/reference/github-action.md +164 -0
  52. package/built/docs/reference/index.md +23 -0
  53. package/built/docs/reference/jetbrains.md +119 -0
  54. package/built/docs/reference/license-key-install.md +73 -0
  55. package/built/docs/reference/remote-recording-api.md +97 -0
  56. package/built/docs/reference/uninstalling-appmap.md +109 -0
  57. package/built/docs/reference/vscode.md +125 -0
  58. package/built/docs/setup-appmap-in-ci/example-projects.md +20 -0
  59. package/built/docs/setup-appmap-in-ci/how-it-works.md +42 -0
  60. package/built/docs/setup-appmap-in-ci/in-circleci.md +422 -0
  61. package/built/docs/setup-appmap-in-ci/in-github-actions.md +176 -0
  62. package/built/docs/setup-appmap-in-ci/index.md +21 -0
  63. package/built/docs/setup-appmap-in-ci/matrix-builds.md +224 -0
  64. package/built/docs/setup-appmap-in-ci/troubleshooting.md +70 -0
  65. package/built/docs/setup-appmap-in-your-code-editor/add-appmap-to-your-code-editor.md +43 -0
  66. package/built/docs/setup-appmap-in-your-code-editor/appmap-analysis.md +76 -0
  67. package/built/docs/setup-appmap-in-your-code-editor/generate-appmaps-from-tests.md +92 -0
  68. package/built/docs/setup-appmap-in-your-code-editor/generate-appmaps-with-remote-recording.md +111 -0
  69. package/built/docs/setup-appmap-in-your-code-editor/generate-appmaps-with-request-recording.md +79 -0
  70. package/built/docs/setup-appmap-in-your-code-editor/how-appmap-works.md +165 -0
  71. package/built/docs/setup-appmap-in-your-code-editor/index.md +23 -0
  72. package/built/docs/setup-appmap-in-your-code-editor/navigating-appmaps.md +58 -0
  73. package/built/docs/setup-appmap-in-your-code-editor/navigating-code-objects.md +66 -0
  74. package/built/docs/unused_for_now_index.html +11 -0
  75. package/built/rpc/appmap/stats.js +1 -1
  76. package/built/rpc/appmap/stats.js.map +1 -1
  77. package/built/rpc/explain/explain.js +6 -1
  78. package/built/rpc/explain/explain.js.map +1 -1
  79. package/built/rpc/explain/navie/navie-local.js +6 -2
  80. package/built/rpc/explain/navie/navie-local.js.map +1 -1
  81. package/built/rpc/explain/navie/navie-remote.js +5 -1
  82. package/built/rpc/explain/navie/navie-remote.js.map +1 -1
  83. package/package.json +3 -3
@@ -0,0 +1,310 @@
1
+ ---
2
+ layout: docs
3
+ title: Docs - Reference
4
+ toc: true
5
+ reference: true
6
+ name: AppMap Agent for Java
7
+ step: 5
8
+ ---
9
+
10
+ # AppMap Agent for Java
11
+
12
+ - [About](#about)
13
+ - [Supported versions](#supported-versions)
14
+ - [Tests recording](#tests-recording)
15
+ - [Using IntelliJ IDEA Run Configurations](#using-intellij-idea-run-configurations)
16
+ - [Recording tests with Maven](#recording-tests-with-maven)
17
+ - [Recording tests with Gradle](#recording-tests-with-gradle)
18
+ - [Other build systems](#other-build-systems)
19
+ - [Requests recording](#requests-recording)
20
+ - [Requests recording in Spring Boot and Spring Web Framework](#requests-recording-in-spring-boot-and-spring-web-framework)
21
+ - [Requests recording in Spark Framework](#requests-recording-in-spark-framework)
22
+ - [Remote recording](#remote-recording)
23
+ - [Process recording](#process-recording)
24
+ - [Code Block Recording](#code-block-recording)
25
+ - [Configuration](#configuration)
26
+ - [Annotations](#annotations)
27
+ - [@Labels](#labels)
28
+ - [Usage](#usage)
29
+ - [@NoAppMap](#noappmap)
30
+ - [Usage](#usage-1)
31
+ - [System Properties](#system-properties)
32
+ - [GitHub repository](#github-repository)
33
+
34
+ ## About
35
+
36
+ `appmap-agent` is a Java agent JAR for recording [AppMaps](https://github.com/getappmap/appmap) of your code.
37
+
38
+ {% include docs/what_is_appmap_snippet.md %}
39
+
40
+ ### Supported versions
41
+
42
+ {% include docs/java_support_matrix.html %}
43
+
44
+ ## Tests recording
45
+
46
+ ### Using IntelliJ IDEA Run Configurations
47
+
48
+ If you're using JetBrains IntelliJ IDEA, we recommend using [run configurations to create AppMaps](/docs/reference/jetbrains#create-appmaps-with-tests).
49
+
50
+ ### Recording tests with Maven
51
+
52
+ Alternatively, you may record your tests with the
53
+ [AppMap Maven plugin](/docs/reference/appmap-maven-plugin#installation).
54
+
55
+ ### Recording tests with Gradle
56
+
57
+ Alternatively, you may record your tests with the
58
+ [AppMap Gradle plugin](/docs/reference/appmap-gradle-plugin#installation).
59
+
60
+ ### Other build systems
61
+
62
+ You can download the latest release of `appmap-agent-<version>.jar` from [https://mvnrepository.com/artifact/com.appland/appmap-agent/latest](https://mvnrepository.com/artifact/com.appland/appmap-agent/latest).
63
+
64
+ Both the AppMap plugin for IntelliJ and the AppMap extension for VS Code automatically download
65
+ the latest the AppMap Java agent, and store it locally in `$HOME/.appmap/lib/java/appmap.jar`.
66
+
67
+ The recorder is run as a Java agent. Currently, it must be started along with
68
+ the JVM. This is done by passing the `-javaagent` argument to your
69
+ JVM when recording tests. For example:
70
+
71
+ ```shell
72
+ $ java -javaagent:$HOME/.appmap/lib/java/appmap.jar myapp.jar
73
+ ```
74
+
75
+ ## Requests recording
76
+ `appmap-java` can automatically record and save an AppMap for each HTTP server request which it processes. This functionality is currently supported for applications built using [Spring Boot](https://spring.io/projects/spring-boot), Servlet-stack web applications built using [Spring Framework](https://docs.spring.io/spring-framework/reference/web.html), and [Spark Framework](http://sparkjava.com/).
77
+
78
+ ### Requests recording in Spring Boot and Spring Web Framework
79
+ For Spring Boot and Spring Web Framework applications, `appmap-java` installs a ServletListener during initialization that will create recordings. The listener starts the recording before the servlet's `service` method is called, and ends the recording once `service` returns.
80
+
81
+ For Spring Boot, `appmap-java` adds the listener when the Spring Application is initialized.
82
+
83
+ For Spring Web Framework, `appmap-java` adds the listener when Spring's servlet container is initialized.
84
+
85
+ ### Requests recording in Spark Framework
86
+ For Spark Framework, `appmap-java` wraps Sparks' Handler with a HandlerWrapper that manages recording.
87
+
88
+ ## Remote recording
89
+
90
+ `appmap-java` supports the [AppMap remote recording API](/docs/reference/remote-recording-api).
91
+ This functionality is provided by the AppMap agent. It will hook into the Java servlets API, injecting the remote recording routes into the servlet chain.
92
+
93
+ **Note** Your application must be running in a servlet container (e.g. Tomcat, Jetty, etc.) for remote recording to work.
94
+
95
+ 1. Start your application with the AppMap agent enabled
96
+ 1. [IntelliJ - "Start with Appmap"](/docs/reference/jetbrains.html#start-with-appmap-for-java)
97
+ 2. Command line - run your Servlet-based application with the `javaagent` JVM argument:
98
+
99
+ ```shell
100
+ $ java -javaagent:$HOME/.appmap/lib/java/appmap.jar -jar target/*.jar
101
+ ```
102
+
103
+ 2. Start and stop the recording
104
+ 1. [IntelliJ](/docs/reference/jetbrains.html#remote-recording)
105
+ 2. [VSCode](/docs/reference/vscode.html#remote-recording)
106
+
107
+ ## Process recording
108
+
109
+ `appmap-java` can record an entire Java process from start to finish.
110
+
111
+ 1. Set the Java system property `appmap.recording.auto=true`. You must set this system property as a JVM argument.
112
+ If you are using a graphical run configuration, add the option `-Dappmap.recording.auto=true` to the "VM options" field.
113
+ If you are running on the command line, add the option `-Dappmap.recording.auto=true` to the JVM CLI arguments.
114
+
115
+ 2. Start your application with the AppMap agent enabled using one of these approaches:
116
+ 1. [IntelliJ - "Start with Appmap"](/docs/reference/jetbrains.html#start-with-appmap-for-java)
117
+ 2. Command line - run your Servlet-based application with the `javaagent` JVM argument:
118
+
119
+ ```shell
120
+ $ java -javaagent:$HOME/.appmap/lib/java/appmap.jar -jar target/*.jar
121
+ ```
122
+
123
+ Other related options such as `appmap.recording.file` and `appmap.recording.name` are also available. Consult the [Configuration](#configuration) section for details.
124
+
125
+ ## Code Block Recording
126
+
127
+ You can use the Java function `com.appland.appmap.record.Recording#record` to record a specific span of code. With this method, you can control exactly what code is recorded, and where the recording is saved.
128
+
129
+ This code snippet illustrates how to use the `record()` function to record a block of code, and then write the AppMap data to a file:
130
+
131
+ ```java
132
+ final Recorder recorder = Recorder.getInstance();
133
+
134
+ final MyClass myClass = new MyClass();
135
+ Recording recording = recorder.record(() -> {
136
+ for (int i = 0; i < 10; i++) {
137
+ myClass.myMethod();
138
+ }
139
+ });
140
+ StringWriter sw = new StringWriter();
141
+ recording.readFully(true, sw);
142
+
143
+ // Now write the recorded AppMap data to a file. The file name should end in ".appmap.json".
144
+ try (PrintWriter out = new PrintWriter("runnable-recording.appmap.json")) {
145
+ out.println(sw.toString());
146
+ }
147
+ catch (FileNotFoundException ex) {
148
+ ex.printStackTrace();
149
+ System.exit(1);
150
+ }
151
+ ```
152
+ {: .example-code}
153
+
154
+
155
+ ## Configuration
156
+
157
+ When you run your program, the agent reads configuration settings from
158
+ `appmap.yml`. Here's a sample configuration file for a typical Java project:
159
+
160
+ ```
161
+ # 'name' should generally be the same as the code repo name.
162
+ name: MyProject
163
+ language: java
164
+ appmap_dir: tmp/appmap
165
+ packages:
166
+ - path: com.mycorp.myproject
167
+ exclude: [ com.mycorp.myproject.MyClass#MyMethod ]
168
+ - path: org.springframework.web
169
+ shallow: true
170
+ exclude:
171
+ - org.springframework.web.util
172
+ - path: java.util.logging
173
+ methods:
174
+ - class: Logger
175
+ name: log
176
+
177
+ ```
178
+
179
+ - **name** Provides the project name (required)
180
+ - **appmap_dir** The directory where AppMaps will be saved by request recording. If unset, a default based on the project's build configuration file will be used.
181
+ - **packages** A list describing how packages should be instrumented. For backwards compatibility, classes and methods can also be specified here. New projects should use the `methods` property to specify which methods to instrument.
182
+
183
+ **packages**
184
+
185
+ Each entry in the `packages` list is a YAML object which has the following keys:
186
+
187
+ * **path** A Java package, class, or method that will be instrumented.
188
+ * **exclude** A list of fully-qualified sub-packages, sub-classes
189
+ and sub-methods that will be ignored. The exclude list only applies to the
190
+ `path` specified in the same package entry.
191
+
192
+ * **shallow** When set to `true`, only the first function call entry into a
193
+ package will be recorded. Subsequent function calls within the same package
194
+ are not recorded unless code execution leaves the package and re-enters it.
195
+ Default: `false`.
196
+
197
+ * **methods** A list of YAML objects describing how specific methods should be handled.
198
+ * **class** a regular expressiom matching names of classes in the package
199
+ * **name** a regular expression matching names of methods in **class** that should be instrumented
200
+ * **labels** (optional) a list of labels that should be applied to all matching methods.
201
+
202
+ Each of the **class** and **name** regular expressions is a
203
+ [java.util.regex.Pattern
204
+ ](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html). They
205
+ will be surrounded with `\A(` `)\z` to match whole symbols. This means, in the
206
+ example above, `log` will match exactly that method of `Logger`, but not the
207
+ `logp` or `logrb` methods. To match all three methods, use `log(|p|rb)` or
208
+ `log.*`. To include the literal symbols `.` or `$` in the patterns, they must be
209
+ properly escaped: `\.` or `\$`.
210
+
211
+ If the **methods** attribute is specified for a package, each element in the
212
+ list will be matched in the order specified, and only the matching methods will
213
+ be instrumented. When the **methods** attribute is set, the **exclude**
214
+ attribute is ignored.
215
+
216
+ ## Annotations
217
+ The `appmap-java` annotations are provided in the package `com.appland:appmap-annotation`, available on [Maven Central](https://search.maven.org/artifact/com.appland/appmap-annotation). To use them, add that package as a dependency in your build configuration file (`pom.xml`, `build.gradle`).
218
+
219
+ ### @Labels
220
+ `appmap-java` suports the addition of [code labels](https://appmap.io/docs/appmap-overview.html#features) through the `com.appland.appmap.annotation.Labels` annotation.
221
+
222
+ #### Usage
223
+ Once the `Labels` annotation is available, you can apply it to methods in your application. For example:
224
+
225
+ ```
226
+ import com.appland.appmap.annotation.Labels;
227
+
228
+ public class ExampleClass {
229
+ ...
230
+ @Labels({"label1", "label2"})
231
+ public void labeledFunction() {
232
+ ...
233
+ }
234
+ }
235
+ ```
236
+
237
+ When `labeledFunction` appears in an AppMap, it will have the labels `label1` and `label2`.
238
+
239
+ ### @NoAppMap
240
+ The `NoAppMap` annotation can be used to disable recording of JUnit test methods. If applied to a specific method, that method will not generate an AppMap. Alternatively, it can be applied to a test class to disable generation of AppMaps for all test methods in the class.
241
+
242
+ #### Usage
243
+ Example of annotating a test method:
244
+
245
+ ```
246
+ import com.appland.appmap.annotation.NoAppMap;
247
+ ...
248
+
249
+ public class TestClass {
250
+ @Test
251
+ public void testMethod1() {
252
+ ...
253
+ }
254
+
255
+ @NoAppMap
256
+ @Test
257
+ public void testMethod2() {
258
+ ...
259
+ }
260
+ }
261
+ ```
262
+ `testMethod1` will generate an AppMap, and `testMethod2` will not.
263
+
264
+ Example of annotating a test class:
265
+ ```
266
+ import com.appland.appmap.annotation.NoAppMap;
267
+ ...
268
+
269
+ @NoAppMap
270
+ public class UnrecordedTestClass {
271
+ @Test
272
+ public void testMethod1() {
273
+ ...
274
+ }
275
+
276
+ @Test
277
+ public void testMethod2() {
278
+ ...
279
+ }
280
+ }
281
+ ```
282
+ No AppMaps will be generated for the tests in `UnrecordedTestClass`.
283
+
284
+ ## System Properties
285
+
286
+ - `appmap.config.file` Path to the `appmap.yml` config file. Default:
287
+ _appmap.yml_
288
+ - `appmap.output.directory` Output directory for `.appmap.json` files. Default:
289
+ `./tmp/appmap`
290
+ - `appmap.debug` Enable debug logging. Default: `null` (disabled)
291
+ - `appmap.event.valueSize` Specifies the length of a value string before
292
+ truncation occurs. If set to `0`, truncation is disabled. Default: `1024`
293
+ - `appmap.record.private` Record private methods, as well as methods with
294
+ package and protected access. Default: `false` (no private methods will be
295
+ recorded).
296
+ - `appmap.recording.auto` Automatically begin recording at boot time. Default:
297
+ `false`
298
+ - `appmap.recording.file` The file name of the automatic recording to be
299
+ emitted. Note that the file name will still be prefixed by
300
+ - `appmap.recording.requests` If `true`, create a recording for each HTTP server request (for
301
+ supported frameworks). Default: `true`.
302
+ `appmap.output.directory`. Default: `$TIMESTAMP.appmap.json`
303
+ - `appmap.recording.name` Populates the `metadata.name` field of the AppMap.
304
+ Default: `$TIMESTAMP`
305
+
306
+
307
+ ## GitHub repository
308
+
309
+ [https://github.com/getappmap/appmap-java](https://github.com/getappmap/appmap-java)
310
+
@@ -0,0 +1,163 @@
1
+ ---
2
+ layout: docs
3
+ title: Docs - Reference
4
+ toc: true
5
+ reference: true
6
+ name: AppMap for Java - Maven Plugin
7
+ step: 6
8
+ ---
9
+
10
+ # AppMap Maven plugin
11
+
12
+ - [AppMap Maven plugin](#appmap-maven-plugin)
13
+ - [About](#about)
14
+ - [Installation](#installation)
15
+ - [Tests recording](#tests-recording)
16
+ - [Plugin goals](#plugin-goals)
17
+ - [Plugin configuration](#plugin-configuration)
18
+ - [Configuring Surefire](#configuring-surefire)
19
+ - [Troubleshooting](#troubleshooting)
20
+ - [Running without modifying `pom.xml`](#running-without-modifying-pomxml)
21
+ - [GitHub repository](#github-repository)
22
+
23
+ ## About
24
+
25
+ The AppMap Maven Plugin provides simple method for recording AppMaps in running
26
+ tests in Maven projects and a seamless integration into CI/CD pipelines. The
27
+ client agent requires `appmap.yml` configuration file, see
28
+ [appmap-java](./appmap-java) for details.
29
+
30
+ ## Installation
31
+
32
+ First, ensure you have a
33
+ [properly configured `appmap.yml`](./appmap-java#configuration)
34
+ in your root project directory.
35
+
36
+ Next, add the following plugin definition to your `pom.xml`:
37
+ ```xml
38
+ <!-- the appmap plugin element goes to build/plugins -->
39
+ <plugin>
40
+ <groupId>com.appland</groupId>
41
+ <artifactId>appmap-maven-plugin</artifactId>
42
+ <version>${appmap.maven-plugin-version}</version>
43
+ <executions>
44
+ <execution>
45
+ <phase>process-test-classes</phase>
46
+ <goals>
47
+ <goal>prepare-agent</goal>
48
+ </goals>
49
+ </execution>
50
+ </executions>
51
+ </plugin>
52
+ ```
53
+ {: .example-code}
54
+
55
+ ## Tests recording
56
+
57
+ The AppMap agent will automatically record your tests when you run
58
+ ```shell
59
+ mvn test
60
+ ```
61
+ {: .example-code}
62
+
63
+ By default, AppMap files are output to `tmp/appmap`.
64
+
65
+ ## Plugin goals
66
+
67
+ - `prepare-agent` - adds the AppMap Java agent to the JVM
68
+ - `print-jar-path` - prints the path to the `appmap-agent.jar` file in the local Maven cache
69
+
70
+ Example:
71
+ ```shell
72
+ mvn com.appland:appmap-maven-plugin:print-jar-path
73
+ ```
74
+ {: .example-code}
75
+
76
+ or
77
+
78
+ ```shell
79
+ mvnw com.appland:appmap-maven-plugin:print-jar-path
80
+ ```
81
+ {: .example-code}
82
+
83
+ ## Plugin configuration
84
+
85
+ - `configFile` Path to the `appmap.yml` config file. Default: _./appmap.yml_
86
+ - `outputDirectory` Output directory for `.appmap.json` files. Default:
87
+ _./tmp/appmap_
88
+ - `skip` Agent won't record tests when set to true. Default: _false_
89
+ - `debug` Enable debug flags as a comma separated list. Accepts: `info`,
90
+ `hooks`, `http`, `locals` Default: _info_
91
+ - `debugFile` Specify where to output debug logs. Default:
92
+ _tmp/appmap/agent.log_
93
+ - `eventValueSize` Specifies the length of a value string before truncation
94
+ occurs. If set to 0, truncation is disabled. Default: _1024_
95
+
96
+
97
+ ## Configuring Surefire
98
+ Some configuration parameters of the Surefire plugin may prevent the appmap plugin
99
+ from being activated when the tests are run:
100
+ 1. `forkCount` may not be set to `0`. Please set it to a value larger than `0` or
101
+ remove this configuration parameter from `pom.xml`
102
+ 3. If `argLine` is specified, it must include `@{argLine}`
103
+
104
+ Example:
105
+ ```
106
+ <plugin>
107
+ <groupId>org.apache.maven.plugins</groupId>
108
+ <artifactId>maven-surefire-plugin</artifactId>
109
+ <version>${maven-surefire-plugin.version}</version>
110
+ <configuration>
111
+ <forkCount>1</forkCount>
112
+ <reuseForks>true</reuseForks>
113
+ <argLine>
114
+ @{argLine} --illegal-access=permit
115
+ </argLine>
116
+ </configuration>
117
+ </plugin>
118
+ ```
119
+
120
+ ## Troubleshooting
121
+
122
+ **I have no `tmp/appmap` directory**
123
+ It's likely that the agent is not running. Double check the `prepare-agent`
124
+ goal is being run. If the JVM is being forked at any point, make sure the
125
+ `javaagent` argument is being propagated to the new process. Additionally
126
+ check that the Surefire plugin configuration is not preventing the agent
127
+ from running. See ["Configuring Surefire"](#configuring-surefire) for more
128
+ information.
129
+
130
+ **`*.appmap.json` files are present, but appear empty or contain little data**
131
+ Double check your `appmap.yml`. This usually indicates that the agent is
132
+ functioning as expected, but no classes or methods referenced in the
133
+ `appmap.yml` configuration are being executed. You may need to adjust the
134
+ packages being recorded. Follow this link for more information:
135
+ [AppMap java configuration](./appmap-java#configuration).
136
+
137
+ **My tests aren't running or I'm seeing `The forked VM terminated without
138
+ properly saying goodbye.`**
139
+ Check the agent log (defaults to `tmp/appmap/agent.log`) and/or the
140
+ Maven Surefire dumpstream (`target/surefire-reports/${DATETIME}.dumpstream`).
141
+ This is typically indicative of an invalid `appmap.yml` configuration.
142
+
143
+ **I have a test failure that only occurs while the agent is attached**
144
+ Please open an issue at [getappmap/appmap-java](https://github.com/getappmap/appmap-java/issues).
145
+ Attach a link to the source code or repository (if available), as well as any
146
+ other relevant information including:
147
+ - the contents of `appmap.yml`
148
+ - the run command used (such as `mvn test`)
149
+ - output of the run command
150
+ - any Maven Surefire dumpstreams generated
151
+ (`target/surefire-reports/${DATETIME}.dumpstream`)
152
+
153
+ ## Running without modifying `pom.xml`
154
+ By specifying the fully-qualified goal, the agent can be run without any
155
+ additional configuration:
156
+ ```sh
157
+ mvn com.appland:appmap-maven-plugin:prepare-agent test
158
+ ```
159
+ {: .example-code}
160
+
161
+ ## GitHub repository
162
+
163
+ [https://github.com/getappmap/appmap-maven-plugin](https://github.com/getappmap/appmap-maven-plugin)
@@ -0,0 +1,185 @@
1
+ ---
2
+ layout: docs
3
+ title: Docs - Reference
4
+ toc: true
5
+ reference: true
6
+ name: AppMap Agent for Node.js
7
+ step: 5
8
+ redirect_from: [/docs/reference/appmap-agent-js]
9
+ ---
10
+
11
+ # AppMap Agent for Node.js
12
+
13
+ **Note**: this agent is currently in early access. It replaces [appmap-agent-js](/docs/reference/appmap-agent-js) which is no longer in active development. [Let us know](https://github.com/getappmap/appmap-node/issues)
14
+ if your project is unable to create AppMaps with `appmap-node`.
15
+
16
+ - [About](#about)
17
+ - [Supported versions](#supported-versions)
18
+ - [Usage](#usage)
19
+ - [Configuration](#configuration)
20
+ - [Tests recording](#tests-recording)
21
+ - [Recording Mocha, Jest, or Vitest test cases](#recording-mocha-jest-or-vitest-test-cases)
22
+ - [Remote recording](#remote-recording)
23
+ - [Process recording](#process-recording)
24
+ - [Request recording](#request-recording)
25
+ - [Viewing AppMaps](#viewing-appmaps)
26
+ - [GitHub repository](#github-repository)
27
+ - [Troubleshooing](#troubleshooting)
28
+
29
+ ## About
30
+
31
+ `appmap-node` records [AppMaps](https://appmap.io) of your Node.js applications.
32
+
33
+ {% include docs/what_is_appmap_snippet.md %}
34
+
35
+ ### Supported versions
36
+
37
+ {% include docs/node_support_matrix.html %}
38
+
39
+ AppMap for Node.js can record applications written in both JavaScript and TypeScript.
40
+
41
+ ## Usage
42
+
43
+ ```
44
+ npx appmap-node <launch command>
45
+ ```
46
+ {: .example-code}
47
+
48
+ AppMap for Node.js wraps your existing application launch command, and typically does not require
49
+ any special installation or configuration.
50
+
51
+ For example, if your Node.js application is normally run with the command `npm run dev`, the following
52
+ command would create AppMap recordings of that application's behavior when it runs:
53
+
54
+ ```console
55
+ $ npx appmap-node npm run dev
56
+ ```
57
+ {: .example-code}
58
+
59
+ The `appmap-node` command works by passing a modified version of the environment variable `NODE_OPTIONS`
60
+ to the launch command. This allows it to work with any Node.js command, including ones based on `npm`,
61
+ `npx`, `node`, or even shell scripts that launch Node.js applications.
62
+
63
+ AppMaps are saved to the directory `tmp/appmap` by default, and each AppMap file ends in `.appmap.json`.
64
+
65
+ ## Configuration
66
+
67
+ When you run your program, the agent reads configuration settings from `appmap.yml`. If not found, a default config file will be created. This is typically appropriate for most projects but you're welcome to review and adjust it.
68
+
69
+ Here's a sample configuration file for a typical JavaScript project:
70
+
71
+ ```yaml
72
+ name: MyApp
73
+ appmap_dir: tmp/appmap
74
+ packages:
75
+ - path: .
76
+ exclude:
77
+ - node_modules
78
+ - .yarn
79
+ ```
80
+ {: .example-code}
81
+
82
+ - **name** Provides the project name (autodetected from *package.json*).
83
+ - **appmap_dir** Directory to place the appmaps in. Defaults to `tmp/appmap`.
84
+ - **packages** A list of paths which should be instrumented.
85
+
86
+ **packages**
87
+
88
+ Each entry in the `packages` list is a YAML object which has the following keys:
89
+
90
+ - **path** A path to JavaScript source files; if the project is transpiled, this should include the final js files. Relative paths are resolved with respect to *appmap.yml* location.
91
+ - **exclude** A list of path, functions and methods that will be ignored. The exclude list only applies to the *path* specified in the same package entry. Paths are resolved with respect to that *path*. For example:
92
+
93
+ ```yaml
94
+ packages:
95
+ - path: dist/users
96
+ exclude:
97
+ - util.js
98
+ - findUser
99
+ - UsersController.index
100
+ - path: dist # catch-all to instrument the rest of the code
101
+ ```
102
+ {: .example-code}
103
+
104
+ ## Tests recording
105
+
106
+ When running test cases with `appmap-node`, a new AppMap file will be created for each unique test case.
107
+
108
+ ### Recording Mocha, Jest, or Vitest test cases
109
+
110
+ Wrap your existing `mocha`, `jest`, or `vitest` test command with `appmap-node`. For example:
111
+
112
+ ```console
113
+ $ npx appmap-node mocha specs/test.js
114
+ $ npx appmap-node npm test
115
+ $ npx appmap-node yarn test
116
+ ```
117
+ {: .example-code}
118
+
119
+ When the tests are complete, the AppMaps will be stored in the default output directory `tmp/appmap/<test-framework>`,
120
+ where `<test-framework>` will be one of `mocha`, `jest`, or `vitest`.
121
+
122
+ {% include vimeo.html id='921256248' %}
123
+
124
+ ## Remote recording
125
+
126
+ The `appmap-node` agent supports the [AppMap remote recording API](/docs/reference/remote-recording-api).
127
+ AppMap adds HTTP APIs that can be used to toggle recording on and off after an application has started.
128
+ Remote recording is useful when you'd like to record only during a specific time during your application's execution.
129
+
130
+ 1. Run `appmap-node` as normal, passing your application's starting command as the arguments.
131
+ 2. `appmap-node` will start the app and inject itself in its http stack. It will listen for [remote recording requests](/docs/reference/remote-recording-api).
132
+ 3. Start the remote recording:
133
+ - [in VS Code](/docs/reference/vscode.html#remote-recording)
134
+ - [in JetBrains IDEs](/docs/reference/jetbrains.html#remote-recording)
135
+ - [with curl](/docs/reference/remote-recording-api)
136
+ 4. Interact with your application's API or UI to so that those features get recorded.
137
+ 5. Stop the recording using the AppMap code editor plugin or curl to save the new AppMap to disk.
138
+
139
+ {% include vimeo.html id='921270684' %}
140
+
141
+ ## Request Recording
142
+
143
+ AppMap for Node.js supports Request Recording. This feature automatically records an AppMap for each HTTP request
144
+ served by the application at runtime.
145
+
146
+ Request recording occurs automatically once any HTTP requests are served, and does not require special
147
+ configuration. Pass your application launch command as the argument to `npx appmap-node` and make HTTP requests
148
+ to your application as normal.
149
+
150
+ Each API request served will create an AppMap representing the full processing of that single HTTP
151
+ request, and will be stored in `tmp/appmap/requests`.
152
+
153
+ {% include vimeo.html id='921273327' %}
154
+
155
+ ## Process recording
156
+
157
+ In the absence of tests or HTTP requests, AppMap can record an entire
158
+ Node.js application's execution from start to finish.
159
+
160
+ Run the `appmap-node` command and give it an argument for starting your application, and it will record the entire
161
+ application's behavior by default.
162
+
163
+ ```
164
+ npx appmap-node <add your Node.js application launch command here>
165
+ ```
166
+ {: .example-code}
167
+
168
+ Then interact with your app using its UI or API, and AppMaps will be generated automatically.
169
+
170
+
171
+ ## Viewing AppMaps
172
+
173
+ Recorded AppMap are saved as `.appmap.json` files `tmp/appmap`.
174
+
175
+ Follow the documentation for your IDE to open recorded `.appmap.json` AppMap files:
176
+ - [in VS Code](/docs/reference/vscode)
177
+ - [in JetBrains IDEs](/docs/reference/jetbrains)
178
+
179
+ ## GitHub repository
180
+
181
+ [https://github.com/getappmap/appmap-node](https://github.com/getappmap/appmap-node)
182
+
183
+ ## Troubleshooting
184
+
185
+ If you run into any issues, please make sure if you have the latest version by running `npx appmap-node@latest` first.