From eb2c38509c6e75f238bb34995a0f90481aa41adf Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 11:34:06 +0200 Subject: [PATCH 01/38] Take back ownership of the Plugin --- .github/dependabot.yml | 6 ++ .github/release-drafter.yml | 59 +++++++++++++++++++ .github/workflows/ci.yml | 39 ++++++++++++ .github/workflows/draft.yml | 17 ++++++ .github/workflows/release.yml | 36 +++++++++++ .github/workflows/scala-steward.yml | 18 ++++++ .gitlab-ci.yml | 17 ------ .gitmodules | 4 -- .scalafmt.conf | 35 ++++++++++- LICENSE | 21 ------- README.md | 30 +++------- build.sbt | 26 ++++++-- project/ReleaseSettings.scala | 1 - project/plugins.sbt | 8 +-- publish.sbt | 9 --- scala-common | 1 - .../scala/com/colisweb/sbt/DatadogAPM.scala | 56 +++++++----------- 17 files changed, 262 insertions(+), 121 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/draft.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/scala-steward.yml delete mode 100644 .gitlab-ci.yml delete mode 100644 .gitmodules delete mode 100644 LICENSE delete mode 120000 project/ReleaseSettings.scala delete mode 100644 publish.sbt delete mode 160000 scala-common diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..120c689 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..6d9c0a2 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,59 @@ +name-template: '$RESOLVED_VERSION' +tag-template: '$RESOLVED_VERSION' + +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: minor + +categories: + - title: 'Features' + label: 'enhancement' + - title: 'Bug Fixes' + label: 'bug' + +exclude-labels: + - 'skip' + +autolabeler: + - label: 'bug' + title: + - '/.*\[fix\].*/' + - label: 'patch' + title: + - '/.*\[fix\].*/' + - label: 'enhancement' + title: + - '/.*\[feat\].*/' + - label: 'minor' + title: + - '/.*\[feat\].*/' + - label: 'skip' + title: + - '/.*\[skip\].*/' + - label: 'major' + title: + - '/.*\[breaking\].*/' + +replacers: + - search: '/\[feat\]/g' + replace: '' + - search: '/\[fix\]/g' + replace: '' + - search: '/\[skip\]/g' + replace: '' + - search: '/\[breaking\]/g' + replace: '' + +template: | + # What's Changed + + $CHANGES + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cf5189a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + pull_request: + types: [ opened, reopened, synchronize ] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + check-latest: true + - name: Run scalafix and scalafmt + run: sbt 'scalafmtSbtCheck; scalafmtCheckAll;' + + ci: + runs-on: ubuntu-latest + steps: + - run: env + shell: bash + - uses: actions/checkout@v3 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + check-latest: true + + - name: Compile code + shell: bash + run: sbt 'clean;Test/compile' diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml new file mode 100644 index 0000000..ea6bf45 --- /dev/null +++ b/.github/workflows/draft.yml @@ -0,0 +1,17 @@ +name: Release Drafter + +on: + push: + branches: + - main + + pull_request: + types: [opened, reopened, synchronize] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5.19.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fc2d96f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Release + +# Triggered when a draft released is "published" (not a draft anymore) +on: + release: + types: [ published ] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - run: env + shell: bash + - uses: actions/checkout@v3 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + check-latest: true + + - name: Compile code + shell: bash + run: sbt 'clean;Test/compile' + + - name: Get the Github Release version + id: vars + run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}" + + - name: Publish package + run: sbt publish + env: + RELEASE_TAG: ${{ env.RELEASE_TAG }} diff --git a/.github/workflows/scala-steward.yml b/.github/workflows/scala-steward.yml new file mode 100644 index 0000000..fcb17f6 --- /dev/null +++ b/.github/workflows/scala-steward.yml @@ -0,0 +1,18 @@ +name: Launch Scala Steward + +# This workflow will launch everyday at 00:00 +on: + schedule: + - cron: '0 0 * * 1-5' + +jobs: + scala-steward: + runs-on: ubuntu-latest + env: + GH_READ_PACKAGES: ${{ secrets.GH_READ_PACKAGES }} + name: Launch Scala Steward + steps: + - name: Launch Scala Steward + uses: scala-steward-org/scala-steward-action@v2 + with: + github-token: ${{ secrets.SCALA_STEWARD }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 43ff03f..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,17 +0,0 @@ -include: - - 'https://colisweb-open-source.gitlab.io/ci-common/v13.12.0/templates/scala.yml' - -test sbt-datadog: - extends: .sbt-test - tags: - - aws - -version sbt-datadog: - extends: .version - tags: - - aws - -publish sbt-datadog: - extends: .sonatype-publish - tags: - - aws diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ea8811a..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "scala-common"] - path = scala-common - url = ../scala-common.git - branch = v1.6.0 diff --git a/.scalafmt.conf b/.scalafmt.conf index fba648e..bfec643 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,3 +1,32 @@ -version = 3.0.0 -style = defaultWithAlign -maxColumn = 120 +version = "3.0.6" +runner.dialect = scala212 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 +maxColumn = 140 +align.preset = most +continuationIndent.defnSite = 2 +assumeStandardLibraryStripMargin = true +docstrings.style = Asterisk +lineEndings = preserve +includeCurlyBraceInSelectChains = true +danglingParentheses.preset = true +optIn.annotationNewlines = true +newlines.alwaysBeforeMultilineDef = false +newlines.implicitParamListModifierPrefer = before +trailingCommas = multiple +docstrings.wrap = no + +rewrite.rules = [RedundantBraces, SortModifiers] + +rewrite.sortModifiers.order = [ + "implicit", "override", "private", "protected", "final", "sealed", "abstract", "lazy" +] +rewrite.redundantBraces.generalExpressions = false +rewrite.redundantBraces.stringInterpolation = true +rewriteTokens = { + "⇒": "=>" + "→": "->" + "←": "<-" +} + +project.excludePaths = [ + "glob:**/modules/caliban-client/src/main/scala/io/conduktor/devtools/api/client/generated/**.scala" +] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 08ae9fb..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Colisweb - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index f56ef7d..181e62f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # sbt-datadog -[ ![Download](https://api.bintray.com/packages/colisweb/sbt-plugins/sbt-datadog/images/download.svg) ](https://bintray.com/colisweb/sbt-plugins/sbt-datadog/_latestVersion) +## Disclaimer + +⚠️ **This is a fork of the original (that I also wrote a long time ago) [Colisweb/sbt-datadog](https://github.com/Colisweb/sbt-datadog)** ⚠️ + +# Documentation This project is highly inspired by the fantastic [sbt-newrelic](https://github.com/gilt/sbt-newrelic) project. @@ -21,7 +25,7 @@ Add the following to your `project/plugins.sbt` file: ```scala -addSbtPlugin("com.colisweb" % "sbt-datadog" % "2.1.0") +addSbtPlugin("com.guizmaii" % "sbt-datadog" % "2.1.0") ``` To enable the Datadog APM for your project, add the `DatadogAPM` auto-plugin to your project. @@ -38,7 +42,7 @@ Configuration To use a specific Datadog Java APM Agent version, add the following to your `build.sbt` file: ```scala -datadogApmVersion := "0.74.1" +datadogApmVersion := "0.98.1" ``` #### `datadogServiceName` @@ -89,26 +93,6 @@ You can use your **host** (where you code run) environment variables in the valu datadogAgentPort := "${MY_DD_PORT}" ``` -#### `datadogEnableNetty` - -Netty Http Server and Client Instrumentation. Default value is `false`. - -To use another value, add the following to your `build.sbt` file: - -```scala -datadogEnableNetty := true -``` - -#### `datadogEnableAkkaHttp` - -Akka-Http Server and Lagom Framework Instrumentation. Default value is `false`. - -To use another value, add the following to your `build.sbt` file: - -```scala -datadogEnableAkkaHttp := true -``` - #### `datadogEnableDebug` To return debug level application logs, enable debug mode with this flag. Default value is `false`. diff --git a/build.sbt b/build.sbt index bdf9bcc..43ad88c 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,25 @@ +organization := "com.guizmaii" name := "sbt-datadog" -scalaVersion := "2.12.14" +version := sys.env.getOrElse("RELEASE_TAG", "0.0.1-SNAPSHOT") +scalaVersion := "2.12.15" sbtPlugin := true -ThisBuild / pushRemoteCacheTo := Some( - MavenCache("local-cache", baseDirectory.value / sys.env.getOrElse("CACHE_PATH", "sbt-cache")) -) + addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") + +val GITHUB_OWNER = "guizmaii" +val GITHUB_PROJECT = "sbt-datadog" + +ThisBuild / publishMavenStyle := true +ThisBuild / publishTo := Some( + s"GitHub $GITHUB_OWNER Apache Maven Packages of $GITHUB_PROJECT" at s"https://maven.pkg.github.com/$GITHUB_OWNER/$GITHUB_PROJECT" +) + +ThisBuild / resolvers += s"GitHub $GITHUB_OWNER Apache Maven Packages" at s"https://maven.pkg.github.com/$GITHUB_OWNER/_/" +ThisBuild / credentials += Credentials( + "GitHub Package Registry", + "maven.pkg.github.com", + GITHUB_OWNER, + env("GITHUB_TOKEN").getOrElse(throw new RuntimeException("Missing env variable: `GITHUB_TOKEN`")), +) + +def env(v: String): Option[String] = sys.env.get(v) diff --git a/project/ReleaseSettings.scala b/project/ReleaseSettings.scala deleted file mode 120000 index 5d36fb5..0000000 --- a/project/ReleaseSettings.scala +++ /dev/null @@ -1 +0,0 @@ -../scala-common/ReleaseSettings.scala \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 2c86939..3865da6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.12") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.1") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.2.2") diff --git a/publish.sbt b/publish.sbt deleted file mode 100644 index c5c7c88..0000000 --- a/publish.sbt +++ /dev/null @@ -1,9 +0,0 @@ -ReleaseSettings.globalReleaseSettings -ReleaseSettings.buildReleaseSettings( - details = "Utilities to use tracing alongside a comprehensive instrumentation, like when using Datadog's java-agent.", - licenseName = "MIT", - licenseUrl = "http://opensource.org/licenses/MIT", - projectName = "sbt-datadog" -) - -ThisBuild / developers := List(Developers.JulesIvanic) diff --git a/scala-common b/scala-common deleted file mode 160000 index e9e4541..0000000 --- a/scala-common +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9e4541b08b9348133d921711d9ffe0c76e393c2 diff --git a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala b/src/main/scala/com/colisweb/sbt/DatadogAPM.scala index b0ac507..d811452 100644 --- a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala +++ b/src/main/scala/com/colisweb/sbt/DatadogAPM.scala @@ -3,35 +3,33 @@ package com.colisweb.sbt import com.typesafe.sbt.SbtNativePackager._ import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin.autoImport.bashScriptExtraDefines import com.typesafe.sbt.packager.archetypes.scripts.{BashStartScriptPlugin, BatStartScriptPlugin} -import sbt.Keys._ import sbt._ +import sbt.Keys._ import sbt.librarymanagement.DependencyFilter -/** Eagerly inspired by https://github.com/gilt/sbt-newrelic - */ +/** + * Eagerly inspired by https://github.com/gilt/sbt-newrelic + */ object DatadogAPM extends AutoPlugin { object autoImport { - lazy val datadogApmVersion = settingKey[String]("Datadog APM agent version") - lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location") + lazy val datadogApmVersion = settingKey[String]("Datadog APM agent version") + lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location") 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" ) - lazy val datadogAgentHost = taskKey[String]( + lazy val datadogAgentHost = taskKey[String]( """Hostname for where to send traces to. If using a containerized environment, configure this to be the host ip. See our docker docs for additional detail. Default value: "localhost"""" ) - lazy val datadogAgentPort = + lazy val datadogAgentPort = taskKey[String]("Port number the Agent is listening on for configured host. Default value: 8126") - lazy val datadogEnableNetty = taskKey[Boolean]("Netty Http Server and Client Instrumentation. Default value: false") - lazy val datadogEnableAkkaHttp = - taskKey[Boolean]("Akka-Http Server and Lagom Framework Instrumentation. Default value: false") lazy val datadogEnableDebug = taskKey[Boolean]("To return debug level application logs, enable debug mode. Default value: false") - lazy val datadogGlobalTags = taskKey[Map[String, String]]( + 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" ) } - import autoImport._ + import autoImport.* override def requires = BashStartScriptPlugin && BatStartScriptPlugin @@ -39,23 +37,19 @@ object DatadogAPM extends AutoPlugin { override lazy val projectSettings = Seq( ivyConfigurations += DatadogConfig, - datadogApmVersion := "0.74.1", - datadogJavaAgent := findDatadogJavaAgent(update.value), - datadogServiceName := name.value, - datadogAgentHost := "localhost", - datadogAgentPort := "8126", - datadogEnableNetty := false, - datadogEnableAkkaHttp := false, - datadogEnableDebug := false, - datadogGlobalTags := Map.empty, - libraryDependencies += "com.datadoghq" % "dd-java-agent" % datadogApmVersion.value % DatadogConfig, - mappings in Universal += datadogJavaAgent.value -> "datadog/dd-java-agent.jar", + datadogApmVersion := "0.98.1", + datadogJavaAgent := findDatadogJavaAgent(update.value), + datadogServiceName := name.value, + datadogAgentHost := "localhost", + datadogAgentPort := "8126", + 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.service.name=${datadogServiceName.value}"""", bashScriptExtraDefines += s"""addJava "-Ddd.agent.host=${datadogAgentHost.value}"""", bashScriptExtraDefines += s"""addJava "-Ddd.agent.port=${datadogAgentPort.value}"""", - bashScriptExtraDefines += s"""addJava "-Ddd.integration.netty.enabled=${datadogEnableNetty.value}"""", - bashScriptExtraDefines += s"""addJava "-Ddd.integration.akka-http.enabled=${datadogEnableAkkaHttp.value}"""", bashScriptExtraDefines += { val debugEnabled = datadogEnableDebug.value if (debugEnabled) s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"""" @@ -63,15 +57,9 @@ object DatadogAPM extends AutoPlugin { }, bashScriptExtraDefines += { 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) => - val tags = globalTags.map { case (key, value) => s"$key:$value" }.mkString(",") - s"""addJava -Ddd.trace.global.tags=$tags""" - } - } + val tags = globalTags.map { case (key, value) => s"$key:$value" }.mkString(",") + s"""addJava -Ddd.trace.global.tags=$tags""" + }, ) private[this] def findDatadogJavaAgent(report: UpdateReport) = report.matching(datadogFilter).head From f951b2ffb85dbb6b1b2add26a4b5110516b133c6 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 12:20:59 +0200 Subject: [PATCH 02/38] Use the Unix Socket by default to connect to the agent (#4) --- build.sbt | 4 +- .../scala/com/colisweb/sbt/DatadogAPM.scala | 41 +++++++++++++------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/build.sbt b/build.sbt index 43ad88c..ca3ff4b 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,9 @@ ThisBuild / credentials += Credentials( "GitHub Package Registry", "maven.pkg.github.com", GITHUB_OWNER, - env("GITHUB_TOKEN").getOrElse(throw new RuntimeException("Missing env variable: `GITHUB_TOKEN`")), + (env("GITHUB_TOKEN") orElse env("GH_PACKAGES_TOKEN")).getOrElse( + throw new RuntimeException("Missing env variable: `GITHUB_TOKEN` or `GH_PACKAGES_TOKEN`") + ), ) def env(v: String): Option[String] = sys.env.get(v) diff --git a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala b/src/main/scala/com/colisweb/sbt/DatadogAPM.scala index d811452..313d906 100644 --- a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala +++ b/src/main/scala/com/colisweb/sbt/DatadogAPM.scala @@ -12,20 +12,32 @@ import sbt.librarymanagement.DependencyFilter */ object DatadogAPM extends AutoPlugin { + /** + * See: + * - https://docs.datadoghq.com/tracing/setup_overview/setup/java/?tab=containers + * - https://docs.datadoghq.com/agent/kubernetes/apm/?tab=ipport#configure-your-application-pods-in-order-to-communicate-with-the-datadog-agent + */ + sealed trait TraceAgentUrl + object TraceAgentUrl { + final case class TraceAgentHttpUrl(host: String, port: String) extends TraceAgentUrl + final case class TraceAgentUnixSocketUrl(socket: String) extends TraceAgentUrl + + final val defaultHttpUrl: TraceAgentUrl = TraceAgentHttpUrl("localhost", "8126") + final val defaultUnixSocketUrl: TraceAgentUrl = TraceAgentUnixSocketUrl("/var/run/datadog/apm.socket") + } + object autoImport { - lazy val datadogApmVersion = settingKey[String]("Datadog APM agent version") - lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location") - lazy val datadogServiceName = taskKey[String]( + lazy val datadogApmVersion = settingKey[String]("Datadog APM agent version") + lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location") + 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" ) - lazy val datadogAgentHost = taskKey[String]( - """Hostname for where to send traces to. If using a containerized environment, configure this to be the host ip. See our docker docs for additional detail. Default value: "localhost"""" + lazy val datadogAgentTraceUrl = taskKey[TraceAgentUrl]( + "Configures how the APM communicates with the Datadog agent. By default it uses the default Datadog Unix Socket `/var/run/datadog/apm.socket`. More information, see https://docs.datadoghq.com/agent/kubernetes/apm/?tab=ipport#configure-your-application-pods-in-order-to-communicate-with-the-datadog-agent" ) - lazy val datadogAgentPort = - taskKey[String]("Port number the Agent is listening on for configured host. Default value: 8126") - lazy val datadogEnableDebug = + lazy val datadogEnableDebug = taskKey[Boolean]("To return debug level application logs, enable debug mode. Default value: false") - lazy val datadogGlobalTags = taskKey[Map[String, String]]( + 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" ) } @@ -40,16 +52,19 @@ object DatadogAPM extends AutoPlugin { datadogApmVersion := "0.98.1", datadogJavaAgent := findDatadogJavaAgent(update.value), datadogServiceName := name.value, - datadogAgentHost := "localhost", - datadogAgentPort := "8126", + 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.service.name=${datadogServiceName.value}"""", - bashScriptExtraDefines += s"""addJava "-Ddd.agent.host=${datadogAgentHost.value}"""", - bashScriptExtraDefines += s"""addJava "-Ddd.agent.port=${datadogAgentPort.value}"""", + bashScriptExtraDefines += { + datadogAgentTraceUrl.value match { + case TraceAgentUrl.TraceAgentHttpUrl(host, port) => s"""addJava "-Ddd.trace.agent.url=http://$host:$port"""" + case TraceAgentUrl.TraceAgentUnixSocketUrl(socket) => s"""addJava "-Ddd.trace.agent.url=unix://$socket"""" + } + }, bashScriptExtraDefines += { val debugEnabled = datadogEnableDebug.value if (debugEnabled) s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"""" From 535cadb5012ecc3ed6fb8e5d04fe6c34e0739377 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 12:49:24 +0200 Subject: [PATCH 03/38] Update documentation (#5) --- README.md | 36 ++++++++++--------- .../scala/com/colisweb/sbt/DatadogAPM.scala | 4 +-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 181e62f..c5aa992 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,7 @@ Installation Add the following to your `project/plugins.sbt` file: ```scala - -addSbtPlugin("com.guizmaii" % "sbt-datadog" % "2.1.0") +addSbtPlugin("com.guizmaii" % "sbt-datadog" % "3.0.0") ``` To enable the Datadog APM for your project, add the `DatadogAPM` auto-plugin to your project. @@ -61,36 +60,41 @@ You can use your **host** (where you code run) environment variables in the valu datadogServiceName := "another name ${MY_HOST_ENV_VAR}" ``` -#### `datadogAgentHost` +#### `datadogAgentTraceUrl` -By default, the agent `agent.host` value is `localhost`. +Defines how the APM will communicate with the Datadog Agent. -To use another value, add the following to your `build.sbt` file: +Two ways are available: + - via Unix Socket (default) + - via HTTP -```scala -datadogAgentHost := "127.0.0.1" -``` +By default, the agent `trace.agent.url` value is `/var/run/datadog/apm.socket`. -You can use your **host** (where you code run) environment variables in the value: +To use a different Unix Socket, add the following to your `build.sbt` file: ```scala -datadogAgentHost := "${MY_DD_HOST_IP}" +datadogAgentTraceUrl := TraceAgentUnixSocketUrl(socket = "/my/directory/my.socket") ``` -#### `datadogAgentPort` +To use the default HTTP URL (`locahost:8126`), add the following to your `build.sbt` file: -By default, the agent `agent.port` value is `"8126"`. +```scala +datadogAgentTraceUrl := TraceAgentUrl.defaultHttpUrl +``` -To use another value, add the following to your `build.sbt` file: +To use a custom HTTP URL, add the following to your `build.sbt` file: ```scala -datadogAgentPort := "9999" +datadogAgentTraceUrl := TraceAgentHttpUrl(host = "my.host.address.com", port = "8888") ``` -You can use your **host** (where you code run) environment variables in the value: + +You can use your **host** (where you code run) environment variables in the values: ```scala -datadogAgentPort := "${MY_DD_PORT}" +datadogAgentTraceUrl := TraceAgentHttpUrl(host = "${MY_DD_HOST_IP}", port = "8888") +// Or +datadogAgentTraceUrl := TraceAgentUnixSocketUrl(socket = "${MY_DD_UNIX_SOCKET}") ``` #### `datadogEnableDebug` diff --git a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala b/src/main/scala/com/colisweb/sbt/DatadogAPM.scala index 313d906..cc6b85b 100644 --- a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala +++ b/src/main/scala/com/colisweb/sbt/DatadogAPM.scala @@ -22,8 +22,8 @@ object DatadogAPM extends AutoPlugin { final case class TraceAgentHttpUrl(host: String, port: String) extends TraceAgentUrl final case class TraceAgentUnixSocketUrl(socket: String) extends TraceAgentUrl - final val defaultHttpUrl: TraceAgentUrl = TraceAgentHttpUrl("localhost", "8126") - final val defaultUnixSocketUrl: TraceAgentUrl = TraceAgentUnixSocketUrl("/var/run/datadog/apm.socket") + final val defaultHttpUrl: TraceAgentUrl = TraceAgentHttpUrl(host = "localhost", port = "8126") + final val defaultUnixSocketUrl: TraceAgentUrl = TraceAgentUnixSocketUrl(socket = "/var/run/datadog/apm.socket") } object autoImport { From 8a10020e67f931b4b15f3c1b30fd04b991c8a8ac Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 12:56:59 +0200 Subject: [PATCH 04/38] Fix release process (#6) --- .github/workflows/release.yml | 2 +- build.sbt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc2d96f..360cebb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,4 +33,4 @@ jobs: - name: Publish package run: sbt publish env: - RELEASE_TAG: ${{ env.RELEASE_TAG }} + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} diff --git a/build.sbt b/build.sbt index ca3ff4b..cd65f08 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,9 @@ -organization := "com.guizmaii" -name := "sbt-datadog" -version := sys.env.getOrElse("RELEASE_TAG", "0.0.1-SNAPSHOT") -scalaVersion := "2.12.15" -sbtPlugin := true +organization := "com.guizmaii" +name := "sbt-datadog" +version := sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT") +versionScheme := Some("semver-spec") +scalaVersion := "2.12.15" +sbtPlugin := true addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") From e006a18e38455cbf5d55a98a56b3d9b78e9273a7 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 13:02:41 +0200 Subject: [PATCH 05/38] Fix release process (#7) --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 360cebb..7a935c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,4 +33,5 @@ jobs: - name: Publish package run: sbt publish env: + GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }} RELEASE_VERSION: ${{ steps.vars.outputs.tag }} From a5d305f6deb1acf11e50b9f1f20060f8b0c01e6b Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 14:16:54 +0200 Subject: [PATCH 06/38] Fix release process (#8) --- build.sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index cd65f08..a0e3d52 100644 --- a/build.sbt +++ b/build.sbt @@ -10,13 +10,13 @@ addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") val GITHUB_OWNER = "guizmaii" val GITHUB_PROJECT = "sbt-datadog" -ThisBuild / publishMavenStyle := true -ThisBuild / publishTo := Some( +publishMavenStyle := true +publishTo := Some( s"GitHub $GITHUB_OWNER Apache Maven Packages of $GITHUB_PROJECT" at s"https://maven.pkg.github.com/$GITHUB_OWNER/$GITHUB_PROJECT" ) -ThisBuild / resolvers += s"GitHub $GITHUB_OWNER Apache Maven Packages" at s"https://maven.pkg.github.com/$GITHUB_OWNER/_/" -ThisBuild / credentials += Credentials( +resolvers += s"GitHub $GITHUB_OWNER Apache Maven Packages" at s"https://maven.pkg.github.com/$GITHUB_OWNER/_/" +credentials += Credentials( "GitHub Package Registry", "maven.pkg.github.com", GITHUB_OWNER, From 223f94c66ddf792c5a44cb87397f7f30eade9b5f Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 15:51:04 +0200 Subject: [PATCH 07/38] Fix release process (#9) --- build.sbt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index a0e3d52..bc20239 100644 --- a/build.sbt +++ b/build.sbt @@ -10,12 +10,6 @@ addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") val GITHUB_OWNER = "guizmaii" val GITHUB_PROJECT = "sbt-datadog" -publishMavenStyle := true -publishTo := Some( - s"GitHub $GITHUB_OWNER Apache Maven Packages of $GITHUB_PROJECT" at s"https://maven.pkg.github.com/$GITHUB_OWNER/$GITHUB_PROJECT" -) - -resolvers += s"GitHub $GITHUB_OWNER Apache Maven Packages" at s"https://maven.pkg.github.com/$GITHUB_OWNER/_/" credentials += Credentials( "GitHub Package Registry", "maven.pkg.github.com", @@ -24,5 +18,9 @@ credentials += Credentials( throw new RuntimeException("Missing env variable: `GITHUB_TOKEN` or `GH_PACKAGES_TOKEN`") ), ) +publishMavenStyle := true +publishTo := Some( + s"GitHub $GITHUB_OWNER Apache Maven Packages of $GITHUB_PROJECT" at s"https://maven.pkg.github.com/$GITHUB_OWNER/$GITHUB_PROJECT" +) def env(v: String): Option[String] = sys.env.get(v) From 8b67a6bb35c33aafc649b83808fc2d5f678e719f Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 7 Apr 2022 16:17:45 +0200 Subject: [PATCH 08/38] Publish to Maven Central instead of Github Packages (which doesn't work) (#10) --- .github/workflows/release.yml | 17 ++++++----------- build.sbt | 25 +++++++++---------------- project/plugins.sbt | 1 + 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a935c1..3124a8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,22 +16,17 @@ jobs: shell: bash - uses: actions/checkout@v3 - uses: coursier/cache-action@v6 + - uses: olafurpg/setup-gpg@v3 - uses: actions/setup-java@v3 with: distribution: temurin java-version: 11 check-latest: true - - name: Compile code - shell: bash - run: sbt 'clean;Test/compile' - - - name: Get the Github Release version - id: vars - run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}" - - name: Publish package - run: sbt publish + run: sbt 'clean;Test/compile;ci-release' env: - GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }} - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/build.sbt b/build.sbt index bc20239..4b7d988 100644 --- a/build.sbt +++ b/build.sbt @@ -7,20 +7,13 @@ sbtPlugin := true addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") -val GITHUB_OWNER = "guizmaii" -val GITHUB_PROJECT = "sbt-datadog" - -credentials += Credentials( - "GitHub Package Registry", - "maven.pkg.github.com", - GITHUB_OWNER, - (env("GITHUB_TOKEN") orElse env("GH_PACKAGES_TOKEN")).getOrElse( - throw new RuntimeException("Missing env variable: `GITHUB_TOKEN` or `GH_PACKAGES_TOKEN`") - ), -) -publishMavenStyle := true -publishTo := Some( - s"GitHub $GITHUB_OWNER Apache Maven Packages of $GITHUB_PROJECT" at s"https://maven.pkg.github.com/$GITHUB_OWNER/$GITHUB_PROJECT" +homepage := Some(url("https://github.com/guizmaii/sbt-datadog")), +licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) +developers := List( + Developer( + "guizmaii", + "Jules Ivanic", + "jules.ivanic@gmail.com", + url("https://blog.jules-ivanic.com/"), + ) ) - -def env(v: String): Option[String] = sys.env.get(v) diff --git a/project/plugins.sbt b/project/plugins.sbt index 3865da6..2e34382 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,3 +2,4 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6" addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.1") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.2.2") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From aca78610ebff1ee1e04ccde870d4651eb2d713c1 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 16:23:07 +0200 Subject: [PATCH 09/38] Fix build.sbt --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4b7d988..d460881 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ sbtPlugin := true addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") -homepage := Some(url("https://github.com/guizmaii/sbt-datadog")), +homepage := Some(url("https://github.com/guizmaii/sbt-datadog")) licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) developers := List( Developer( From c895c22e434d1d5017fac6ed3436d5dc833c41f1 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 16:29:41 +0200 Subject: [PATCH 10/38] Fix versioning --- build.sbt | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sbt b/build.sbt index d460881..dcf6398 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,5 @@ organization := "com.guizmaii" name := "sbt-datadog" -version := sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT") versionScheme := Some("semver-spec") scalaVersion := "2.12.15" sbtPlugin := true From 799a8ddd98fc92b7e9c107f42216f5f214065ac1 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 16:41:01 +0200 Subject: [PATCH 11/38] Fix versioning --- .github/workflows/release.yml | 7 ++++++- build.sbt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3124a8b..ce54d3f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,15 @@ jobs: java-version: 11 check-latest: true + - name: Get the Github Release version + id: vars + run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}" + - name: Publish package - run: sbt 'clean;Test/compile;ci-release' + run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} diff --git a/build.sbt b/build.sbt index dcf6398..d460881 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,6 @@ organization := "com.guizmaii" name := "sbt-datadog" +version := sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT") versionScheme := Some("semver-spec") scalaVersion := "2.12.15" sbtPlugin := true From fe2fd8dad5afb31e3e393b38487dadf4907de486 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 16:55:36 +0200 Subject: [PATCH 12/38] Fix versioning --- .github/workflows/release.yml | 5 ----- build.sbt | 1 - 2 files changed, 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce54d3f..9f8c489 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,6 @@ jobs: java-version: 11 check-latest: true - - name: Get the Github Release version - id: vars - run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}" - - name: Publish package run: sbt ci-release env: @@ -34,4 +30,3 @@ jobs: PGP_SECRET: ${{ secrets.PGP_SECRET }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} diff --git a/build.sbt b/build.sbt index d460881..dcf6398 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,5 @@ organization := "com.guizmaii" name := "sbt-datadog" -version := sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT") versionScheme := Some("semver-spec") scalaVersion := "2.12.15" sbtPlugin := true From d0fb07a012d88ff5a4177cecdebca6e89f19dff3 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 17:20:06 +0200 Subject: [PATCH 13/38] Try( Fix publishing ) --- build.sbt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/build.sbt b/build.sbt index dcf6398..811a740 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,3 @@ -organization := "com.guizmaii" name := "sbt-datadog" versionScheme := Some("semver-spec") scalaVersion := "2.12.15" @@ -6,13 +5,18 @@ sbtPlugin := true addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") -homepage := Some(url("https://github.com/guizmaii/sbt-datadog")) -licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) -developers := List( - Developer( - "guizmaii", - "Jules Ivanic", - "jules.ivanic@gmail.com", - url("https://blog.jules-ivanic.com/"), +inThisBuild( + List( + organization := "com.guizmaii", + homepage := Some(url("https://github.com/guizmaii/sbt-datadog")), + licenses := Seq("Apache-2.0" -> url("http://opensource.org/licenses/https://opensource.org/licenses/Apache-2.0")), + developers := List( + Developer( + "guizmaii", + "Jules Ivanic", + "jules.ivanic@gmail.com", + url("https://blog.jules-ivanic.com/#/"), + ) + ), ) ) From 8b0e0bf0d660fc65afc1f4ef8126bcbe26319e38 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 7 Apr 2022 17:29:57 +0200 Subject: [PATCH 14/38] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5aa992..3cf6d5f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Installation Add the following to your `project/plugins.sbt` file: ```scala -addSbtPlugin("com.guizmaii" % "sbt-datadog" % "3.0.0") +addSbtPlugin("com.guizmaii" % "sbt-datadog" % "4.0.0") ``` To enable the Datadog APM for your project, add the `DatadogAPM` auto-plugin to your project. From add0831d17a9ccd6355eea1e0b69010919d60ce7 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Wed, 13 Apr 2022 15:50:57 +0200 Subject: [PATCH 15/38] Fix package name. Migrate from `com.colisweb.sbt` to `com.guizmaii.sbt` (#11) --- src/main/scala/com/{colisweb => guizmaii}/sbt/DatadogAPM.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/scala/com/{colisweb => guizmaii}/sbt/DatadogAPM.scala (99%) diff --git a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala similarity index 99% rename from src/main/scala/com/colisweb/sbt/DatadogAPM.scala rename to src/main/scala/com/guizmaii/sbt/DatadogAPM.scala index cc6b85b..e36a6ab 100644 --- a/src/main/scala/com/colisweb/sbt/DatadogAPM.scala +++ b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala @@ -1,4 +1,4 @@ -package com.colisweb.sbt +package com.guizmaii.sbt import com.typesafe.sbt.SbtNativePackager._ import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin.autoImport.bashScriptExtraDefines From ad0d3f2801973c88e55dc4dd827364bb74b953cf Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Thu, 21 Apr 2022 18:36:10 +0200 Subject: [PATCH 16/38] Fix: Do not set the `-Ddd.trace.global.tags` if the `globalTags` is empty (#12) --- src/main/scala/com/guizmaii/sbt/DatadogAPM.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala index e36a6ab..aa6b3d2 100644 --- a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala +++ b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala @@ -70,10 +70,12 @@ object DatadogAPM extends AutoPlugin { if (debugEnabled) s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"""" else """echo "Datadog debug mode disabled"""" }, - bashScriptExtraDefines += { + bashScriptExtraDefines ++= { val globalTags = datadogGlobalTags.value - val tags = globalTags.map { case (key, value) => s"$key:$value" }.mkString(",") - s"""addJava -Ddd.trace.global.tags=$tags""" + if (globalTags.nonEmpty) { + val tags = globalTags.map { case (key, value) => s"$key:$value" }.mkString(",") + Seq(s"""addJava "-Ddd.trace.global.tags=$tags"""") + } else Seq.empty }, ) From ac93cc1806926b9a22b2cf325d3af9568a396191 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Tue, 3 May 2022 10:00:22 +0200 Subject: [PATCH 17/38] Update doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cf6d5f..85621aa 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Installation Add the following to your `project/plugins.sbt` file: ```scala -addSbtPlugin("com.guizmaii" % "sbt-datadog" % "4.0.0") +addSbtPlugin("com.guizmaii" % "sbt-datadog" % "4.2.0") ``` To enable the Datadog APM for your project, add the `DatadogAPM` auto-plugin to your project. From 6cf0a3d549490eb087d705deb441056a48509bfd Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Wed, 4 May 2022 17:03:34 +0200 Subject: [PATCH 18/38] Update default Datadog Agent version to the latest version (#14) --- README.md | 2 +- src/main/scala/com/guizmaii/sbt/DatadogAPM.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85621aa..c3bddac 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Installation Add the following to your `project/plugins.sbt` file: ```scala -addSbtPlugin("com.guizmaii" % "sbt-datadog" % "4.2.0") +addSbtPlugin("com.guizmaii" % "sbt-datadog" % "4.3.0") ``` To enable the Datadog APM for your project, add the `DatadogAPM` auto-plugin to your project. diff --git a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala index aa6b3d2..e952078 100644 --- a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala +++ b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala @@ -49,7 +49,7 @@ object DatadogAPM extends AutoPlugin { override lazy val projectSettings = Seq( ivyConfigurations += DatadogConfig, - datadogApmVersion := "0.98.1", + datadogApmVersion := "0.100.0", datadogJavaAgent := findDatadogJavaAgent(update.value), datadogServiceName := name.value, datadogAgentTraceUrl := TraceAgentUrl.defaultUnixSocketUrl, From ebeff7360671684fd20a3c3eb989ba0d497de592 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Wed, 4 May 2022 17:05:58 +0200 Subject: [PATCH 19/38] [CI] Fix scala-steward config (#15) --- .github/workflows/scala-steward.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/scala-steward.yml b/.github/workflows/scala-steward.yml index fcb17f6..9614c99 100644 --- a/.github/workflows/scala-steward.yml +++ b/.github/workflows/scala-steward.yml @@ -8,11 +8,9 @@ on: jobs: scala-steward: runs-on: ubuntu-latest - env: - GH_READ_PACKAGES: ${{ secrets.GH_READ_PACKAGES }} name: Launch Scala Steward steps: - name: Launch Scala Steward uses: scala-steward-org/scala-steward-action@v2 with: - github-token: ${{ secrets.SCALA_STEWARD }} + github-token: ${{ secrets.GITHUB_TOKEN }} From ce0cff22444f643338d6751ab9fd08e6c68a9d5c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 12:35:08 +0200 Subject: [PATCH 20/38] Update sbt-updates to 0.6.2 (#16) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 2e34382..bd8b841 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.1") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.2") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.2.2") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From 1b36d1479d28bb4b136ad4507b42dc63dfca1427 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 12:35:34 +0200 Subject: [PATCH 21/38] Update sbt-tpolecat to 0.2.3 (#17) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Jules Ivanic --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index bd8b841..0ef3151 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.2") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.2.2") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.2.3") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From 76e9da89e09f380a3a98f86a07c5210f895ec93a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 12:35:56 +0200 Subject: [PATCH 22/38] Update scalafmt-core to 3.0.8 (#19) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index bfec643..34ac29a 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.0.6" +version = "3.0.8" runner.dialect = scala212 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 maxColumn = 140 align.preset = most From b5c5464735b1383e88cf2b7dc24481a321557e85 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 23 May 2022 15:59:02 +0200 Subject: [PATCH 23/38] Update scalafmt-core to 3.5.4 (#24) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 34ac29a..3dbd121 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.0.8" +version = "3.5.4" runner.dialect = scala212 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 maxColumn = 140 align.preset = most From e7579bd65e5b0bc677373cd42be216de794f8ab7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 23 May 2022 15:59:13 +0200 Subject: [PATCH 24/38] Update sbt-tpolecat to 0.3.1 (#20) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 0ef3151..8bc07fd 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.2") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.2.3") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From dcb5c7ba20f734be248f910d79cb3db69d826ba2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 May 2022 15:59:23 +0200 Subject: [PATCH 25/38] Bump release-drafter/release-drafter from 5.19.0 to 5.20.0 (#23) Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.19.0 to 5.20.0. - [Release notes](https://github.com/release-drafter/release-drafter/releases) - [Commits](https://github.com/release-drafter/release-drafter/compare/v5.19.0...v5.20.0) --- updated-dependencies: - dependency-name: release-drafter/release-drafter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/draft.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml index ea6bf45..eb77ea3 100644 --- a/.github/workflows/draft.yml +++ b/.github/workflows/draft.yml @@ -12,6 +12,6 @@ jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5.19.0 + - uses: release-drafter/release-drafter@v5.20.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 50dd4daf4f0ebcbb126dd57ee3773ec10649237f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 May 2022 10:57:05 +0200 Subject: [PATCH 26/38] Update scalafmt-core to 3.5.5 (#25) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 3dbd121..9f4f54f 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.5.4" +version = "3.5.5" runner.dialect = scala212 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 maxColumn = 140 align.preset = most From 833dce657657da99085266caf889e93c8d11a96c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 11:49:05 +0200 Subject: [PATCH 27/38] Update scalafmt-core to 3.5.7 (#26) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 9f4f54f..4fb5bd5 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.5.5" +version = "3.5.7" runner.dialect = scala212 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 maxColumn = 140 align.preset = most From 1f60c4620507822660ac598f419135b50db5a543 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 31 May 2022 11:29:57 +0200 Subject: [PATCH 28/38] Update sbt-updates to 0.6.3 (#27) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 8bc07fd..b00085c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.2") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From 82a58480b2a4283b6de0813c6a7681ef56dd3f12 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 07:13:48 +0200 Subject: [PATCH 29/38] Update scalafmt-core to 3.5.8 (#28) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 4fb5bd5..9ea3123 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.5.7" +version = "3.5.8" runner.dialect = scala212 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 maxColumn = 140 align.preset = most From 0e4868344ad4aa53b909ee5bc21fc650f542c42e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:47:59 +0200 Subject: [PATCH 30/38] Update sbt-tpolecat to 0.3.3 (#29) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index b00085c..7d2bbce 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.1") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.3") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From e8858938b9fbbab8eadc9262e24e2f88a9fbc9fa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 09:44:12 +0100 Subject: [PATCH 31/38] Update scala-library to 2.12.16 (#30) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 811a740..7892584 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "sbt-datadog" versionScheme := Some("semver-spec") -scalaVersion := "2.12.15" +scalaVersion := "2.12.16" sbtPlugin := true addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") From 96539f3d2ef15d07f2168994d6a21124ceee9068 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 09:45:02 +0400 Subject: [PATCH 32/38] Update sbt to 1.7.0 (#31) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index f6acff8..85ad641 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.6.2 +sbt.version = 1.7.0 From 289eb0af4918a298b41534fcd691a2b2ae0aa9cf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 09:45:39 +0400 Subject: [PATCH 33/38] Update sbt to 1.7.1 (#32) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 85ad641..d738b85 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.7.0 +sbt.version = 1.7.1 From 198bfd82d11796ad85e8c58cd8b00780d13fa676 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Jul 2022 09:24:00 +0400 Subject: [PATCH 34/38] Update sbt-tpolecat to 0.4.0 (#33) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 7d2bbce..021349b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.3") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.0") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From 1a5dbffb99736dc051d73b356a0a5b5267b0aad4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:26:17 +0400 Subject: [PATCH 35/38] Update sbt-tpolecat to 0.4.1 (#34) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 021349b..78ba083 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.0") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From ed53a999ae85eb0ff672adf2b4ac41607b5a4cfb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 09:35:27 +0200 Subject: [PATCH 36/38] Update sbt-native-packager to 1.9.10 (#35) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7892584..8cdf013 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ versionScheme := Some("semver-spec") scalaVersion := "2.12.16" sbtPlugin := true -addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9" % "provided") +addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.10" % "provided") inThisBuild( List( From 3704de604f64c6877d3d4e2eea43fad739c50354 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Wed, 10 Aug 2022 19:30:36 +0200 Subject: [PATCH 37/38] Remove useless "Datadog debug mode disabled" log (#36) --- .../scala/com/guizmaii/sbt/DatadogAPM.scala | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala index e952078..6963b50 100644 --- a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala +++ b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala @@ -27,17 +27,22 @@ object DatadogAPM extends AutoPlugin { } object autoImport { - lazy val datadogApmVersion = settingKey[String]("Datadog APM agent version") - lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location") - lazy val datadogServiceName = taskKey[String]( + lazy val datadogApmVersion = settingKey[String]("Datadog APM agent version") + + lazy val datadogJavaAgent = taskKey[File]("Datadog agent jar location") + + 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" ) + lazy val datadogAgentTraceUrl = taskKey[TraceAgentUrl]( "Configures how the APM communicates with the Datadog agent. By default it uses the default Datadog Unix Socket `/var/run/datadog/apm.socket`. More information, see https://docs.datadoghq.com/agent/kubernetes/apm/?tab=ipport#configure-your-application-pods-in-order-to-communicate-with-the-datadog-agent" ) - lazy val datadogEnableDebug = + + lazy val datadogEnableDebug = taskKey[Boolean]("To return debug level application logs, enable debug mode. Default value: false") - lazy val datadogGlobalTags = taskKey[Map[String, String]]( + + 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" ) } @@ -65,10 +70,10 @@ object DatadogAPM extends AutoPlugin { case TraceAgentUrl.TraceAgentUnixSocketUrl(socket) => s"""addJava "-Ddd.trace.agent.url=unix://$socket"""" } }, - bashScriptExtraDefines += { + bashScriptExtraDefines ++= { val debugEnabled = datadogEnableDebug.value - if (debugEnabled) s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"""" - else """echo "Datadog debug mode disabled"""" + if (debugEnabled) Seq(s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"""") + else Seq.empty }, bashScriptExtraDefines ++= { val globalTags = datadogGlobalTags.value From 2ebeb17248af9dfb944576dd8d577539315d6bf1 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Wed, 10 Aug 2022 20:02:41 +0200 Subject: [PATCH 38/38] Add `datadogApmEnabled` setting --- README.md | 12 ++++++++++++ src/main/scala/com/guizmaii/sbt/DatadogAPM.scala | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index c3bddac..1a8fd8f 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala index 6963b50..07c97a8 100644 --- a/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala +++ b/src/main/scala/com/guizmaii/sbt/DatadogAPM.scala @@ -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" ) @@ -56,6 +60,7 @@ object DatadogAPM extends AutoPlugin { ivyConfigurations += DatadogConfig, datadogApmVersion := "0.100.0", datadogJavaAgent := findDatadogJavaAgent(update.value), + datadogApmEnabled := true, datadogServiceName := name.value, datadogAgentTraceUrl := TraceAgentUrl.defaultUnixSocketUrl, datadogEnableDebug := false, @@ -63,6 +68,7 @@ object DatadogAPM extends AutoPlugin { 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 {