Skip to content

Commit

Permalink
Add datadogApmEnabled setting (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii authored Aug 10, 2022
1 parent 3704de6 commit b63d8e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ To use a specific Datadog Java APM Agent version, add the following to your `bui
datadogApmVersion := "0.98.1"
```

#### `datadogApmEnabled`

You can easily disable the Datadog APM by settings this setting to `false`.
Note that if you have the `DD_TRACE_ENABLED` environment variable set, it'll take precedence over this setting.
See https://docs.datadoghq.com/tracing/trace_collection/library_config/java/

Default value: `true`

```scala
datadogApmEnabled := true
```

#### `datadogServiceName`

By default, the agent will use the sbt project `name` value as `service.name`.
Expand Down
6 changes: 6 additions & 0 deletions src/main/scala/com/guizmaii/sbt/DatadogAPM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ object DatadogAPM extends AutoPlugin {

lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location")

lazy val datadogApmEnabled = taskKey[Boolean](
"Datadog APM agent enabled. Default: `DD_TRACE_ENABLED` envvar value if present, 'true' otherwise"
)

lazy val datadogServiceName = taskKey[String](
"The name of a set of processes that do the same job. Used for grouping stats for your application. Default value is the sbt project name"
)
Expand All @@ -56,13 +60,15 @@ object DatadogAPM extends AutoPlugin {
ivyConfigurations += DatadogConfig,
datadogApmVersion := "0.100.0",
datadogJavaAgent := findDatadogJavaAgent(update.value),
datadogApmEnabled := true,
datadogServiceName := name.value,
datadogAgentTraceUrl := TraceAgentUrl.defaultUnixSocketUrl,
datadogEnableDebug := false,
datadogGlobalTags := Map.empty,
libraryDependencies += "com.datadoghq" % "dd-java-agent" % datadogApmVersion.value % DatadogConfig,
Universal / mappings += datadogJavaAgent.value -> "datadog/dd-java-agent.jar",
bashScriptExtraDefines += """addJava "-javaagent:${app_home}/../datadog/dd-java-agent.jar"""",
bashScriptExtraDefines += s"""addJava "-Ddd.trace.enabled=${datadogApmEnabled.value}"""",
bashScriptExtraDefines += s"""addJava "-Ddd.service.name=${datadogServiceName.value}"""",
bashScriptExtraDefines += {
datadogAgentTraceUrl.value match {
Expand Down

0 comments on commit b63d8e7

Please sign in to comment.