The New Relic Java agent is compatible with Scala, and supports New Relic API calls, annotations, and custom instrumentation. All information below is supplemental to New Relic's Java agent installation directions.
For Heroku, see Java agent with Scala on Heroku.
Instrument Scala with the Java agent API
Instrument Scala to use the New Relic API class or annotations.
Add the following information to your Scala configuration file:
- Configure using the project/build.scala file
Add the following line (replacing X.Y.Z with the Java agent version you use) to the appDependencies method in your application's
"com.newrelic.agent.java" % "newrelic-api" % "X.Y.Z"
- Configure using the project/build.sbt file
Add the following line (replacing X.Y.Z with the Java agent version you use) to your application's
libraryDependencies += "com.newrelic.agent.java" % "newrelic-api" % "X.Y.Z"
Import the NewRelic class and use it in your application:
import com.newrelic.api.agent.NewRelic ... NewRelic.setTransactionName(null, "/myTransaction");
More API functions
For more about the Java agent API and its functionality, see the Java agent API introduction.
If you use Kamon, take a look at the New Relic Kamon reporter.