Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add option to stop logging debugging information at startup #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/main/scala/com/colisweb/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 datadogGlobalTags = taskKey[Map[String, String]](
"A list of default tags to be added to every span and every JMX metric. Default value: Empty List"
)

lazy val datadogSbtLogStartupDebug = taskKey[Boolean](
"When enabled will log various debugging-related pieces of information on startup. Default value: true"
)
}
import autoImport._

Expand All @@ -45,6 +49,7 @@ object DatadogAPM extends AutoPlugin {
datadogServiceName := name.value,
datadogAgentHost := "localhost",
datadogAgentPort := "8126",
datadogSbtLogStartupDebug := true,
datadogEnableNetty := false,
datadogEnableAkkaHttp := false,
datadogEnableDebug := false,
Expand All @@ -58,19 +63,23 @@ object DatadogAPM extends AutoPlugin {
bashScriptExtraDefines += s"""addJava "-Ddd.integration.netty.enabled=${datadogEnableNetty.value}"""",
bashScriptExtraDefines += s"""addJava "-Ddd.integration.akka-http.enabled=${datadogEnableAkkaHttp.value}"""",
bashScriptExtraDefines += {
val debugLogging = datadogSbtLogStartupDebug.value
val debugEnabled = datadogEnableDebug.value
if (debugEnabled) s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug""""
else """echo "Datadog debug mode disabled""""
else if (debugLogging) """echo "Datadog debug mode disabled""""
else ""
},
bashScriptExtraDefines += {
val debugLogging = datadogSbtLogStartupDebug.value
val globalTags = datadogGlobalTags.value
(globalTags.contains("env"), globalTags.contains("version")) match {
case (false, false) => """echo "Datadog env and app version are not set""""
case (false, true) => """echo "Datadog env is not set""""
case (true, false) => """echo "App version is not set""""
case (true, true) =>
(globalTags.contains("env"), globalTags.contains("version"), debugLogging) match {
case (false, false, true) => """echo "Datadog env and app version are not set""""
case (false, true, true) => """echo "Datadog env is not set""""
case (true, false, true) => """echo "App version is not set""""
case (true, true, _) =>
val tags = globalTags.map { case (key, value) => s"$key:$value" }.mkString(",")
s"""addJava -Ddd.trace.global.tags=$tags"""
case _ => ""
}
}
)
Expand Down