Skip to content

Commit a446e3a

Browse files
authored
Merge pull request #4 from Colisweb/update_to_agent_0.10
Update to agent 0.10
2 parents 2617d6b + 7815cb6 commit a446e3a

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This project is highly inspired by the fantastic [sbt-newrelic](https://github.com/gilt/sbt-newrelic) project.
66

7-
We want to thanks [Gilt](http://tech.gilt.com) for their work on `sbt-newrelic` that allows us to create this project really quickly.
7+
We want to thanks [Gilt](http://tech.gilt.com) for their work on `sbt-newrelic` that allowed us to create this project really quickly.
88

99
Prerequisites
1010
-------------
@@ -39,7 +39,7 @@ Configuration
3939
To use a specific Datadog Java APM Agent version, add the following to your `build.sbt` file:
4040

4141
```scala
42-
datadogVersion := "0.9.0"
42+
datadogVersion := "0.10.0"
4343
```
4444

4545
#### `datadogServiceName`
@@ -74,6 +74,53 @@ You can use your **host** (where you code run) enviroment variables in the value
7474
datadogServiceName := "${MY_DD_HOST_IP}"
7575
```
7676

77+
#### `datadogEnv`
78+
79+
By default, the `env` is not set.
80+
81+
To set the `env`, add the following to your `build.sbt` file:
82+
83+
```scala
84+
datadogEnv := "staging"
85+
```
86+
87+
You can use your **host** (where you code run) enviroment variables in the value:
88+
89+
```scala
90+
datadogEnv := "${MY_ENV}"
91+
```
92+
93+
#### `datadogEnableNetty`
94+
95+
Netty Http Server and Client Instrumentation. Default value is `false`.
96+
97+
To use another value, add the following to your `build.sbt` file:
98+
99+
```scala
100+
datadogEnableNetty := true
101+
```
102+
103+
#### `datadogEnableAkkaHttp`
104+
105+
Akka-Http Server and Lagom Framework Instrumentation. Default value is `false`.
106+
107+
To use another value, add the following to your `build.sbt` file:
108+
109+
```scala
110+
datadogEnableAkkaHttp := true
111+
```
112+
113+
#### `datadogEnableDebug`
114+
115+
To return debug level application logs, enable debug mode with this flag. Default value is `false`.
116+
117+
To use another value, add the following to your `build.sbt` file:
118+
119+
```scala
120+
datadogEnableDebug := true
121+
```
122+
123+
77124
#### Other possible settings
78125

79126
For more configuration option, look at the Datadog Java APM agent documentation: https://docs.datadoghq.com/tracing/setup/java/

src/main/scala/com/colisweb/sbt/DatadogAPM.scala

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import com.typesafe.sbt.SbtNativePackager._
44
import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin.autoImport.bashScriptExtraDefines
55
import com.typesafe.sbt.packager.archetypes.scripts.{BashStartScriptPlugin, BatStartScriptPlugin}
66
import sbt.Keys._
7-
import sbt._
87
import sbt.librarymanagement.DependencyFilter
8+
import sbt.{Def, _}
99

1010
/**
1111
* Eagerly inspired by https://github.com/gilt/sbt-newrelic
@@ -19,6 +19,11 @@ object DatadogAPM extends AutoPlugin {
1919
"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")
2020
lazy val datadogAgentHost = taskKey[String](
2121
"""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"""")
22+
lazy val datadogEnv = taskKey[String]("Environment. https://docs.datadoghq.com/tracing/setup/first_class_dimensions/. By default, this settings is not set")
23+
lazy val datadogEnableNetty = taskKey[Boolean]("Netty Http Server and Client Instrumentation. Default value: false")
24+
lazy val datadogEnableAkkaHttp =
25+
taskKey[Boolean]("Akka-Http Server and Lagom Framework Instrumentation. Default value: false")
26+
lazy val datadogEnableDebug = taskKey[Boolean]("To return debug level application logs, enable debug mode. Default value: false")
2227
}
2328
import autoImport._
2429

@@ -28,15 +33,29 @@ object DatadogAPM extends AutoPlugin {
2833

2934
override lazy val projectSettings = Seq(
3035
ivyConfigurations += DatadogConfig,
31-
datadogVersion := "0.9.0",
36+
datadogVersion := "0.10.0",
3237
datagodJavaAgent := findDatadogJavaAgent(update.value),
3338
datadogServiceName := name.value,
3439
datadogAgentHost := "localhost",
40+
datadogEnv := "",
41+
datadogEnableNetty := false,
42+
datadogEnableAkkaHttp := false,
43+
datadogEnableDebug := false,
3544
libraryDependencies += "com.datadoghq" % "dd-java-agent" % datadogVersion.value % DatadogConfig,
3645
mappings in Universal += datagodJavaAgent.value -> "datadog/dd-java-agent.jar",
3746
bashScriptExtraDefines += """addJava "-javaagent:${app_home}/../datadog/dd-java-agent.jar"""",
3847
bashScriptExtraDefines += s"""addJava "-Ddd.service.name=${datadogServiceName.value}"""",
3948
bashScriptExtraDefines += s"""addJava "-Ddd.agent.host=${datadogAgentHost.value}"""",
49+
bashScriptExtraDefines += s"""addJava "-Ddd.integration.netty.enabled=${datadogEnableNetty.value}"""",
50+
bashScriptExtraDefines += s"""addJava "-Ddd.integration.akka-http.enabled=${datadogEnableAkkaHttp.value}"""",
51+
bashScriptExtraDefines += {
52+
val env = datadogEnv.value
53+
if (env.nonEmpty) s"""addJava "-Ddd.trace.span.tags="env:$env""""" else """echo "Datadog env is not set""""
54+
},
55+
bashScriptExtraDefines += {
56+
val debugEnabled = datadogEnableDebug.value
57+
if (debugEnabled) s"""addJava "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"""" else """echo "Datadog debug mode disabled""""
58+
}
4059
)
4160

4261
private[this] def findDatadogJavaAgent(report: UpdateReport) = report.matching(datadogFilter).head

0 commit comments

Comments
 (0)