Question

I have a Scala Play Framework app in Heroku. I want to install New Relic, but I don't want to add the java agent jar to my git repository. I think the repository should exclusively contain code, configuration files and such, maybe with the exception of static assets such as images. Never binary dependencies.

Is there any way of achieving this?

Was it helpful?

Solution

I found the solution is to add the New Relic binaries from the Maven repository, then to point the Procfile to the right place. The detailed solution is for Scala, but should work in Java too:

  1. Download the newrelic.yml file and add it to your git repository in the root of the Play Framework app.

  2. Add the New Relic dependency to Build.scala:

    val appDependencies = Seq(
      "com.newrelic.agent.java" % "newrelic-agent" % "3.7.0",
      //Other dependencies here
    )
    
    val main = play.Project(appName, appVersion, appDependencies)
    
  3. Add the following to the web: entry of your Play Framework app's Procfile (all in one line):

    -J-javaagent:target/universal/stage/lib/com.newrelic.agent.java.newrelic-agent-3.7.0.jar
    -J-Dnewrelic.config.file=newrelic.yml
    
  4. Commit all your changes and push to your Heroku app's git repository.

  5. Wait for Heroku to build and deploy the app, then a few minutes for New Relic to start displaying data.

  6. Drool at New Relic's InfoPorn! :-D

I found the path where the New Relic agent was being downloaded from the Maven repository by connecting to my Heroku app's terminal (heroku run bash in the CLI) and searching around.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top