I didn't find many articles in Japanese, so I worked while looking at New Relic's official documentation. It will be a memorandum.
You can use the heroku command or the Configure Add-ons on the screen, so add the New Relic add-on. (Since I will go to the management screen of New Relic later, it may be easier from the screen ...?)
Normally, the key will load ** newrelic.yml ** in the same directory as the jar, but we will install a Java Agent to avoid git management of the key.
Register the app name in Config Vars on Heroku with the key ** NEW_RELIC_APP_NAME **. If it is settings.gradle or pom, I think that it should be described in artifactId.
heroku config:set NEW_RELIC_APP_NAME="APP_NAME"
You can get the key from New Relic's admin screen. Select APM When you select Java, this screen will appear, so press "Reveal license key" to get the key. Then register with the key ** NEW_RELIC_LICENSE_KEY **.
heroku config:set NEW_RELIC_LICENSE_KEY="LICENSE_KEY"
In the case of Maven, it is as described on the official document side, and in the case of Gradle, the operation was confirmed as follows.
buld.gradle
dependencies {
.....
compileOnly 'com.newrelic.agent.java:newrelic-java:5.7.0'
}
(At the time of writing, 5.7.0 was the latest.)
The jar is obtained from the management screen of New Relic earlier. When you press the link, the zip will drop, so unzip it and place only "** newrelic.jar **" in the project doco. (Since it is described in the Procfile, I think it can be anywhere.)
Finally, add the ** javaagent ** option to your Procfile. For example, in Springboot, if newrelic.jar is placed directly under the project
Procfile
web: java -jar build/libs/app-0.0.1-SNAPSHOT.jar
↓↓↓↓↓
Procfile
web: java -javaagent:newrelic.jar -jar build/libs/app-0.0.1-SNAPSHOT.jar
It will be.
deploy
After deploying, you will see a screen like this in 5 minutes at the longest, and you will be able to see Web transactions time etc. by selecting the application.
Thank you for your hard work.
It seems to use more memory than I expected. .. .. In the case of my app, I gave up the operation because ** Error R14 (Memory quota exceeded) ** occurred probably because Spring Batch is also running. The memory used will increase with wrinkles.
Recommended Posts