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