How to setup Datadog APM for Java application running with Tomcat

Step 1 – Install and Run Apache Tomcat

Step 2 – Install and Run Datadog Agent

Step 3 – Download dd-java-agent.jar into /opt/ and give permission.

$ cd /opt
$ wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'
$ chmod 777 dd-java-agent.jar 

Step 4 – Edit catalina.sh and following entry

$ vi /opt/apache-tomcat-8.5.61/bin/catalina.sh

# Make sure dd.service and dd.env as per your choice.

CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/dd-java-agent.jar -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.trace.sample.rate=1 -Ddd.service=java -Ddd.env=dev"

Step 4 – Restart Tomcat

$ ps -eaf | grep tomcat | grep dd