This repository showcases how to configure DataDog java agent for Scala tests.
To configure DataDog agent this repo uses sbt-javaagent.
- In your sbt project, open
project/plugins.sbt
(create one if you don't have it) and add following lineaddSbtPlugin("com.github.sbt" % "sbt-javaagent" % "0.1.8")
- In your
build.sbt
navigate to your module (root
in case of this repository) - On your module enable java agent module by adding
.enablePlugins(JavaAgent)
- Within the module settings attach agent of your choice, for DataDog agent do
javaAgents += "com.datadoghq" % "dd-java-agent" % "1.45.0" % "test"
Please note that % "test"
by the end of the line enables the agent within test scope. Please consult scopes section of javaagent plugin for more details.
For DataDog agent to work, you also need to specify environment variables. You can do this in two ways.
If you want to keep the values in sbt, you can do it like this:
envVars := Map(
"DD_CIVISIBILITY_AGENTLESS_ENABLED" -> "true",
"DD_SERVICE" -> "myservcice",
"DD_ENV" -> "local",
"DD_SITE" -> "datadoghq.com",
"DD_CIVISIBILITY_ENABLED" -> "true"
)
Otherwise you can specify the variables within command line execution:
DD_SERVICE=myservcice DD_ENV=local DD_SITE=datadoghq.com DD_CIVISIBILITY_AGENTLESS_ENABLED=true DD_CIVISIBILITY_ENABLED=true sbt
Make sure you also have DD_API_KEY
present in your environment, but it's best not to keep it in your repository and cli invocation.