Java
How to setup recording & monitoring for Java applications

Requirements

To setup RevDeBug you will need to:

Adding RevDeBug repository

Add the following lines to the super pom.xml / build.gradle file in the Java application main node:
Maven
Gradle
1
pom.xml
2
3
<project>
4
...
5
<repositories>
6
<repository>
7
<id>rdb-repo</id>
8
<name>RevDeBug Maven Repo</name>
9
<url>https://release.revdebug.com/repository/maven</url>
10
</repository>
11
</repositories>
12
...
13
</project>
Copied!
1
build.gradle
2
3
repositories {
4
maven {
5
url 'https://nexus.revdebug.com/repository/maven'
6
}
7
}
8
Copied!

Adding RevDeBug dependency

Add the following lines to the super pom.xml / build.gradle file in the Java application main node:
Maven
Gradle
1
pom.xml
2
3
<project>
4
...
5
<dependencies>
6
<dependency>
7
<groupId>com.revdebug</groupId>
8
<artifactId>compiler</artifactId>
9
<version>6.4.0</version>
10
<scope>provided</scope>
11
</dependency>
12
<dependency>
13
<groupId>com.revdebug</groupId>
14
<artifactId>RevDeBug</artifactId>
15
<version>6.4.0</version>
16
</dependency>
17
...
18
</project>
Copied!
1
build.gradle
2
3
dependencies {
4
compileOnly 'com.revdebug:compiler:6.4.0'
5
annotationProcessor 'com.revdebug:compiler:6.4.0' // Required after Gradle v4.10.2
6
implementation 'com.revdebug:RevDeBug:6.4.0'
7
}
8
9
//* Use compile keyword instead of implementation for Gradle version less than 3.0
10
//* Use compile keyword instead of compileOnly for Gradle version less than 2.12
11
Copied!
For spring-boot projects additional exclusion in pom.xml is needed (without it build time dependencies will be packaged with application):
1
pom.xml
2
3
<project>
4
...
5
<build>
6
<plugins>
7
<plugin>
8
<groupId>org.springframework.boot</groupId>
9
<artifactId>spring-boot-maven-plugin</artifactId>
10
<configuration>
11
<excludes>
12
<exclude>
13
<groupId>com.revdebug</groupId>
14
<artifactId>compiler</artifactId>
15
</exclude>
16
</excludes>
17
</configuration>
18
</plugin>
19
...
20
</plugins>
21
</build>
22
...
23
</project>
Copied!

Configure the connection to RevDeBug Server

RevDeBug can be easily added to all projects in the working directory. But if you want, you can add RevDeBug to the selected subset.
Maven - single project
Maven - many projects
Gradle
1
pom.xml
2
3
<project>
4
...
5
<plugins>
6
<plugin>
7
<groupId>org.apache.maven.plugins</groupId>
8
<artifactId>maven-compiler-plugin</artifactId>
9
<version>3.8.1</version>
10
<configuration>
11
<compilerArgs>
12
<arg>-ArecordServerAddress=[SERVER_ADDRESS]</arg>
13
<arg>-ArecordServerPort=42734</arg>
14
<arg>-ArecordingMode=OnEvent</arg>
15
<arg>-AapplicationName=[APP_NAME]</arg>
16
<arg>-AsolutionName=[PROJECT_NAME]</arg>
17
<arg>-AreleaseId=${git.commit.id}</arg>
18
<arg>-AreleaseDisplayName=[DISPLAY_NAME]</arg>
19
<arg>-ArepositoryPath=[STORAGE_PATH]</arg>
20
<arg>-AuploadMetadata=true</arg>
21
<arg>-AforceTLS=false</arg>
22
</compilerArgs>
23
<source>1.8</source>
24
<target>1.8</target>
25
</configuration>
26
</plugin>
27
</plugins>
28
...
29
</project>
Copied!
1
pom.xml
2
<project>
3
<build>
4
...
5
<pluginManagement>
6
<plugins>
7
<plugin>
8
<groupId>org.apache.maven.plugins</groupId>
9
<artifactId>maven-compiler-plugin</artifactId>
10
<version>3.8.1</version>
11
<configuration>
12
<compilerArgs>
13
<arg>-ArecordServerAddress=[SERVER_ADDRESS]</arg>
14
<arg>-ArecordServerPort=42734</arg>
15
<arg>-ArecordingMode=OnEvent</arg>
16
<arg>-AapplicationName=[APP_NAME]</arg>
17
<arg>-AsolutionName=[PROJECT_NAME]</arg>
18
<arg>-AreleaseId=${git.commit.id}</arg>
19
<arg>-AreleaseDisplayName=[DISPLAY_NAME]</arg>
20
<arg>-ArepositoryPath=[STORAGE_PATH]</arg>
21
<arg>-AuploadMetadata=true</arg>
22
<arg>-AlogErrorClass=[LOG_CLASS]</arg>
23
<arg>-AlogErrorMethod=[LOG_METHOD]</arg>
24
<arg>-AREVDEBUG_TRACE_LOG_ERROR=true</arg>
25
<arg>-AforceTLS=false</arg>
26
</compilerArgs>
27
<source>1.8</source>
28
<target>1.8</target>
29
</configuration>
30
</plugin>
31
</plugins>
32
</pluginManagement>
33
...
34
</build>
35
</project>
36
37
Copied!
1
build.gradle
2
3
compileJava {
4
options.compilerArgs = [
5
"-ArecordServerAddress=[SERVER_ADDRESS]",
6
"-ArecordServerPort=42734",
7
"-ArecordingMode=OnEvent",
8
"-AapplicationName=[APP_NAME]",
9
"-AsolutionName=[PROJECT_NAME]",
10
"-AreleaseId=[HASH_COMMIT]",
11
"-AreleaseDisplayName=[DISPLAY_NAME]",
12
"-ArepositoryPath=[STORAGE_PATH]",
13
"-AuploadMetadata=true",
14
"-AlogErrorClass=[LOG_CLASS]",
15
"-AlogErrorMethod=[LOG_METHOD]",
16
"-AREVDEBUG_TRACE_LOG_ERROR=true",
17
"-AforceTLS=false"
18
]}
19
Copied!

Settings overview

There are configurable fields in the connection section of RevDeBug DevOps Monitor:
Name
Explanation
-ArecordServerAddress
IP address or hostname of the recording servers
-ArecordServerPort
Connection port to revdebug
-ArecordingMode
RevDeBug offers ways to register applications:
OnEvent - registers only a specified number of steps back (default 1,000) and the error itself. This mode is very light and well suited for production use
Continuous - records everything that occurred in the application, including every line of code executed, every variable value, every exception and performance data. It is recommended to use this mode only locally in a test environment
MethodMetric - generates CSV files with information about each method occurring in the application and presents them broken down by package name, class name, method name with an initialization line. Additionally, it includes measurements such as the total number of calls, method run times (total time, minimum time and maximum time)
-AapplicationName
Application name for RevDeBug
-AsolutionName
The name of the application that the user will see in revdebug
-AreleaseDisplayName
The name under which the release will be visible on your RevDeBug instance
-AreleaseId
Git hash of the current commit. Option for automating the loading of code in the code view in RevDeBug. If you use maven here you can configure independent git commit loading
-ArepositoryPath
The path to the folder on the application side where its metadata is stored. Eg. 'target/metadata/' (when using Maven) or '${projectDir}/build/metadata/' (when using Gradle)
-AuploadMetadata
Variable whether or not metadata should be sent to your revdebug instance
-AforceTLS
Forces TLS connection with the server. Set this to true if your RevDeBug DevOps Monitor instance has been configured to work with a SSL certificate
-AREVDEBUG_OFF
Defaults to 'false'. Disables RevDeBug instrumentation when set to 'true'. Could be useful for local development and can be set via environment variable "REVDEBUG_OFF".
-AREVDEBUG_TRACE_LOG_ERROR
Enables treating log.error() calls as exceptions and recording them
-AlogErrorClass
Define logger class to use for log.error() recording. Must be fully qualified name, such as ‘org.apache.log4j.Logger’
-AlogErrorMethod
Define method part of log.error() call for logger class specified in AlogErrorClass. For example for log class ‘org.apache.log4j.Logger’ the log error method is ‘error’

Git hash loader

For maven builds to have ${git.commit.id}provided you need to add maven properties extension or use git commit info maven plugin in your project (we highly recommend maven properties extension as plugin lifecycle can break on more complex project structures).
Create .mvn/extensions.xml file in your project's root directory with the contents below:
1
<?xml version="1.0" encoding="UTF-8"?>
2
<extensions>
3
<extension>
4
<groupId>com.github.pascalgn</groupId>
5
<artifactId>properties-maven-extension</artifactId>
6
<version>0.4.0</version>
7
</extension>
8
</extensions>
Copied!

Add RevDeBug Java-agent

  • Download java-agent from nexus repo (link)
  • Unzip the archive and modify config/agent.config file
    • agent.service_name set to your app name
    • collector.backend_service set to point to your record server instance
    • agent.force_tls set to true if your RevDeBug DevOps Monitor instance has been configured to work with an SSL certificate.
  • Attach unzipped agent to your app with java argument: -javaagent:[Path-to-unzipped-agent]/agent/skywalking-agent.jar