Search code examples
javaspringspring-bootnewrelicjavaagents

Spring Boot with New Relic without modifying dependencies


I am trying to configure New Relic to monitor Spring applications created using Spring Boot. The applications are already in a released state and I would like to be able to integrate New Relic without modifying the dependencies of the java applications, as in this question.

Is there any way to include the new relic agent in such a way that restarting the Spring Boot application with new command line arguments will suffice?

EDIT

I had read warnings about using the -javaagent:/path/to/newrelic.jar flag and getting error messages, but had not tried it for myself. It appears that this option works now.

SECOND EDIT

The single spring boot app is reporting two separate applications, one for the Embedded Tomcat server and another for the Java application itself. Would there be a way to resolve this?

THIRD EDIT (for anyone reading this in the future)

My spring boot app was reporting two applications to the New Replic APM tool. In order to avoid this, I now start the java application with an environment variable:

export NEW_RELIC_APP_NAME="my spring boot app"
java -jar spring-boot-app-1.0.jar -javaagent:/path/to/newrelic.jar

Solution

  • Turns out that the instructions for standalone applications works as well for spring boot apps:

    java -jar spring-boot-app-1.0.jar -javaagent:/path/to/newrelic.jar