Join the Preview!
RUM Auto-Instrumentation through Java servlet-based web servers is in Preview.
Request AccessOverview
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
- Java SDK installed using either:
Datadog configuration
- RUM application created in Datadog
- Configuration values ready:
clientToken
applicationId
remoteConfigurationId
Configuration
To get access to configuration steps for this feature, join the preview program.
Troubleshooting
RUM JavaScript tag is not injected
If you don’t see the RUM JavaScript tag injected, try the following steps:
- Check server logs for any error messages related to RUM Auto-Instrumentation
- Verify configuration - ensure all required environment variables defined at the configuration step are set:
DD_RUM_ENABLED=true
DD_RUM_APPLICATION_ID=<your-application-id>
DD_RUM_CLIENT_TOKEN=<your-client-token>
DD_RUM_REMOTE_CONFIGURATION_ID=<your-remote-config-id>
- Enable debug logging by setting
dd.trace.debug=true
(system property) or DD_TRACE_DEBUG=true
(environment variable) - Check HTML response - ensure your server is returning HTML with a
<head>
section - Clear browser cache - cached pages do not show the injected JavaScript
In addition, when debug logging is enabled, you should see a message like this at startup:
DEBUG datadog.trace.api.Config - New instance: Config{..., rumEnabled=true, rumInjectorConfig={"applicationId":"appid","clientToken":"token","site":"datadoghq.com","remoteConfigurationId":"remoteconfigid"}, ...}
This confirms that RUM Auto-Instrumentation is properly configured.
Further reading
Más enlaces, artículos y documentación útiles: