Skip to content

Commit

Permalink
Make the DD_TRACE_ENABLED precedence over -Ddd.trace.enabled work (
Browse files Browse the repository at this point in the history
…#44)

Make the `DD_TRACE_ENABLED` precedence over `-Ddd.trace.enabled` work.

It's documented a taking the precedence in DD doc but doesn't seem to work IRL.
  • Loading branch information
guizmaii authored Sep 6, 2022
1 parent b9c0a5f commit 839bb63
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/main/scala/com/guizmaii/sbt/DatadogAPM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,27 @@ object DatadogAPM extends AutoPlugin {
bashScriptExtraDefines +=
// https://docs.datadoghq.com/profiler/enabling/java/?tab=commandarguments
// We have to check `datadogApmEnabled` to enable profiling because if we activate the profiling but deactivate the APM, the APM will start anyway.
// I'm clearly not an expert in Bash... At least, it's explicit...
s"""
|addJava "-Ddd.trace.enabled=${datadogApmEnabled.value}"
|addJava "-Ddd.profiling.enabled=${datadogApmEnabled.value && datadogProfilingEnabled.value}"
|addJava "-Ddd.profiling.allocation.enabled=${datadogApmEnabled.value && datadogAllocationProfilingEnabled.value}"
|""".stripMargin,
|if [ "$${DD_TRACE_ENABLED}" == "true" ]; then
| export __ENABLE_TRACES__=true
|else
| export __ENABLE_TRACES__=${datadogApmEnabled.value}
|fi
|if [ "$${__ENABLE_TRACES__}" == "true" ]; then
| export __ENABLE_PROFILING__=${datadogProfilingEnabled.value}
|else
| export __ENABLE_PROFILING__=false
|fi
|if [ "$${__ENABLE_TRACES__}" == "true" ]; then
| export __ENABLE_ALLOCATION_PROFILING__=${datadogAllocationProfilingEnabled.value}
|else
| export __ENABLE_ALLOCATION_PROFILING__=false
|fi
|addJava "-Ddd.trace.enabled=$${__ENABLE_TRACES__}"
|addJava "-Ddd.profiling.enabled=$${__ENABLE_PROFILING__}"
|addJava "-Ddd.profiling.allocation.enabled=$${__ENABLE_ALLOCATION_PROFILING__}"
|""".stripMargin.trim,
bashScriptExtraDefines += s"""addJava "-Ddd.service.name=${datadogServiceName.value}"""",
bashScriptExtraDefines += {
datadogAgentTraceUrl.value match {
Expand Down

0 comments on commit 839bb63

Please sign in to comment.