Setting Up RUM with Java
  • 30 Aug 2021
  • 2 Minutes to read
  • Contributors
  • Dark
  • PDF

Setting Up RUM with Java

  • Dark
  • PDF

This document details how to enable RUM for the APM Profiler in your Java application running on Linux or Windows.


1. Install the Latest Version of the Agent and Profiler

Required Agent Versions
  • Windows Agent v4.32+
  • Linux Agent v2.31+
  • Java Profiler 1.33.6+

2. Enable RUM

Follow the RUM Getting Started guide to Enable RUM on your account

3. Setup APM for your Application

Follow the Java Getting Started Guide to configure the profiler for your specific setup. The profiler will need to be properly configured for RUM to function.

4. Configure the RUM Key

In order to identify the data coming from your application pages is tied to your account, you need to make your RUM Key available to your application. This setting is passed to your application via an environment variable, RETRACE_RUM_KEY.

Add the RETRACE_RUM_KEY to the machine Environment Variables. Its value is the RUM Key available in the Retrace RUM configuration screen.

Set the RETRACE_RUM_KEY environment variable so that it is available to the application when it launches. This will vary based on how the application is launched (e.g. via systemd or command line).

5. Add Script Injection to Your Application

The RUM implementation for Java requires a method call in the Stackify Java API library to be added to the pages that you want to report RUM data to Retrace.
JSP page script insertion
JSP pages require adding a call to com.stackify.apm.Stackify.getRUMJavaScriptBlock to the <head> section of each page that you would like tracked.

	<%= com.stackify.apm.Stackify.getRUMJavaScriptBlock() %>
	<title>JSP Sample Page</title>

Spring with ThymeLeaf script insertion

	<th:block th:utext="${T(com.stackify.apm.Stackify).getRUMJavaScriptBlock()}">
	<title>JSP Sample Page</title>

JSF Facelets
In order to use the RUM injection with Facelets, you will need to expose our static method as a function taglib. To do that you will need to create a retrace.taglib.xml file in the WEB-INF folder of your application with these contents:

<?xml version="1.0" encoding="UTF-8"?>
    	<function-signature>java.lang.String getRUMJavaScriptBlock()</function-signature>

Then you will need to reference this taglib in your web.xml file by adding the following:
<context-param> <param-name>javax.faces.FACELETS_LIBRARIES</param-name> <param-value>/WEB-INF/retrace.taglib.xml</param-value> </context-param>
Finally, in the pages that contain the <head> tag for the page that you want to report RUM data, you will need to add the namespace and insert the call as shown here:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns=""
    <f:view contentType="text/html" encoding="UTF-8">
        <ui:insert name="metadata"></ui:insert>
            <title>JakartaEE Faces Sample</title>
            <!-- Required meta tags -->
            <meta charset="utf-8"></meta>
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"></meta>
            <!-- Retrace RUM output Text -->
            <h:outputText escape="false" value="#{retrace:getRUMJavaScriptBlock()}"/>

6. Redeploy your App

Once the previous steps to enable RUM for your account and add the code snippet to your app(s) have been completed, the last step is to deploy the changes to your application.

Viewing RUM Data

Once the following steps have been taken to set up RUM for your apps, data will be reported in the corresponding App Dashboard. To see more information related to what RUM data is presented in the App Dashboard, see the Viewing RUM Data in Retrace help doc.

Was this article helpful?