Overview

RUM Auto-Instrumentation automatically adds RUM monitoring to your web application server, so you can start collecting RUM data by editing a configuration file instead of having to modify your frontend code directly. However, if you want to track specific user actions (custom actions) or add custom event details (event attributes), you still need to add some code to your application.

How it works

The Java SDK works by monitoring your servlet API (which handles web requests and responses), automatically checking each HTTP response your server sends. When it detects an HTML response, it looks for the <head> section and automatically adds the RUM JavaScript code there. The rest of your HTML content remains unchanged. This approach adds minimal overhead, so it works well even with streaming responses (where content is sent in real-time).

Prerequisites

Server requirements

  • Java web application server with Servlet API 3.0 or higher support:
    • Jetty 7+
    • Tomcat 7+
    • GlassFish 3+ / Payara 4.1+
    • JBoss AS 6+ / Wildfly 8+
    • Undertow 1+
    • WebLogic 12+
    • WebSphere AS 8+ / Open Liberty 17+

SDK requirements

Datadog configuration

  • RUM application created in Datadog
  • Configuration values ready:
    • clientToken
    • applicationId
    • remoteConfigurationId

Configuration

Enable RUM injection

RUM SDK injection for Java web application servers can be configured using the usual Java tracing configuration methods. For more information, see Configuring the Java SDK Library.

RUM SDK injection is disabled by default. Enable it by exporting the following environment variables:

export DD_RUM_ENABLED=true
export DD_RUM_APPLICATION_ID=<your-application-id>
export DD_RUM_CLIENT_TOKEN=<your-client-token>
export DD_RUM_REMOTE_CONFIGURATION_ID=<your-remote-config-id>
export DD_RUM_SITE=datadoghq.com # or datadoghq.eu / us3.datadoghq.com / us5.datadoghq.com / ap1.datadoghq.com / ap2.datadoghq.eu

Or use the following Java system properties:

java -Ddd.rum.enabled=true \
  -Ddd.rum.application.id=<your-application-id> \
  -Ddd.rum.client.token=<your-client-token> \
  -Ddd.rum.remote.configuration.id=<your-remote-configuration-id> \
  -Ddd.rum.site=datadoghq.com # or datadoghq.eu / us3.datadoghq.com / us5.datadoghq.com / ap1.datadoghq.com / ap2.datadoghq.eu

Restart your Java web application server to apply the changes.

HTML documents should now contain the Datadog RUM JavaScript tag right before the closing </head>. You may need to clear your browser cache. You should now start receiving data for your Datadog RUM application.

Configuration options

Here are all the configuration options related to RUM SDK injection:

PropertyEnvironment variableValueRequirement
dd.rum.enabledDD_RUM_ENABLEDtrue / falseRequired
dd.rum.application.idDD_RUM_APPLICATION_ID<string>Required
dd.rum.client.tokenDD_RUM_CLIENT_TOKEN<string>Required
dd.rum.siteDD_RUM_SITEdatadoghq.com / us3.datadoghq.com / us5.datadoghq.com / datadoghq.eu / ap1.datadoghq.com / ap2.datadoghq.euOptional, datadoghq.com by default
dd.rum.serviceDD_RUM_SERVICE<string>Optional
dd.rum.environmentDD_RUM_ENVIRONMENT<string>Optional
dd.rum.major.versionDD_RUM_MAJOR_VERSION5 / 6Optional, 6 by default
dd.rum.versionDD_RUM_VERSION<string>Optional
dd.rum.track.user.interactionDD_RUM_TRACK_USER_INTERACTIONtrue / falseOptional
dd.rum.track.resourcesDD_RUM_TRACK_RESOURCEStrue / falseOptional
dd.rum.track.long.tasksDD_RUM_TRACK_LONG_TASKStrue / falseOptional
dd.rum.session.sample.rateDD_RUM_SESSION_SAMPLE_RATEPercentage, from 0 to 100Required if rum.remote.configuration.id is missing
dd.rum.session.replay.sample.rateDD_RUM_SESSION_REPLAY_SAMPLE_RATEPercentage, from 0 to 100Required if rum.remote.configuration.id is missing
dd.rum.remote.configuration.idDD_RUM_REMOTE_CONFIGURATION_ID<string>Required if either rum.session.sample.rate or rum.session.replay.sample.rate is missing

Troubleshooting

Check the Java web application server logs if you don’t see the RUM JavaScript tag injected.

Look for the configuration parsing error message "Unable to configure RUM injection" in the logs. If present, it shows a detailed message about the cause.

Additionally, enabling debug logs using the dd.trace.debug=true system property or the DD_TRACE_DEBUG=true environment variable dumps the Java client library configuration at startup:

DEBUG datadog.trace.api.Config - New instance: Config{..., rumEnabled=true, rumInjectorConfig={"applicationId":"appid","clientToken":"token","site":"datadoghq.com","remoteConfigurationId":"remoteconfigid"}, ...}

Further reading

Additional helpful documentation, links, and articles: