Heroku is a Platform as a Service (PaaS) solution for hosting web applications in various agent languages, including Scala. With New Relic, you can extend Heroku with metrics from New Relic APM, Browser, and Insights.
For non-Scala installations, see Java agent and Heroku.
Contents
Requirements
Before you install New Relic on your Scala app, ensure your app meets these requirements:
- Deploy your Scala app to Heroku, following the Heroku instructions at least through the Deploy the app step.
- Install Java 8.
- Install the New Relic Java agent version 3.17.0 or higher.
Then, enable the New Relic add-on and configure your Heroku environment for New Relic.
Enable the New Relic add-on
After completing the requirements, enable the New Relic add-on:
- Log in to your Heroku account.
- From the New Relic APM Add-On Page, select a subscription plan.
- Select Install New Relic APM, then select your target app from the drop-down.
- Continue with the procedures to configure your Heroku environment for New Relic.
Installing the add-on automatically creates a New Relic account and configures access for Heroku servers.
Configure your Heroku environment for New Relic
After you complete the requirements and enable the New Relic add-on, configure your Scala Heroku environment for New Relic:
-
Edit your
Procfile
to point to the agent jar in your app's root folder. Replace the contents of the file, substitutingX.Y.Z
with the latest agent version:web: target/universal/stage/bin/play-getting-started -Dhttp.port=${PORT} -J-javaagent:/app/target/universal/stage/lib/com.newrelic.agent.java.newrelic-agent-X.Y.Z.jar -J-Dnewrelic.config.file=conf/newrelic.yml
OR
Identify the path to
newrelic.jar
with theJAVA_OPTS
environment variable. -
Edit your
build.sbt
. Call the agent, substitutingX.Y.Z
with the latest Java agent version:- Custom build.sbt
-
name := """play-getting-started""" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayScala) scalaVersion := "2.11.7" libraryDependencies ++= Seq( jdbc, cache, "org.postgresql" % "postgresql" % "9.4-1201-jdbc41", ws ) libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _ ) libraryDependencies ++= Seq("com.newrelic.agent.java" % "newrelic-agent" % "X.Y.Z") libraryDependencies ++= Seq("com.newrelic.agent.java" % "newrelic-api" % "X.Y.Z")
-
Download a customized
newrelic.yml
file from your APM account settings:- How to download a custom
newrelic.yml
-
- Log in to dashboard.heroku.com. Select your app, then select Add-ons > New Relic APM.
- From the New Relic UI's (account dropdown), select Account settings.
- In the Update your New Relic agent section, download the Java SE 8 release.
- Unzip the downloaded file.
-
Copy
newrelic.yml
to thescala-getting-started/conf
directory:
- How to download a custom
- Edit
newrelic.yml
, and customize theapp_name
setting with a descriptive app name. -
In your local terminal, push the changes to the dyno:
git add . git commit -m Your commit message . git push heroku master
-
Open the website in your browser with this Heroku Toolbelt command:
heroku open
Generate some traffic to your app. Wait a few minutes, then check your app's performance: In Heroku, select your app, then select the New Relic add-on. If you don't see the New Relic add-on, select Find More Add Ons, and add the New Relic APM add-on.
Troubleshooting your installation
If no data appears after waiting a few minutes, see No data appears with Heroku (Java).
For more help
Additional documentation resources include:
- Java agent and Heroku (for non-Scala installation on Heroku)
- No data appears with Heroku (troubleshotoing steps after installation)
- Scala installation for Java (Scala installation if you don't use Heroku)