Remove legacy config references.
This commit is contained in:
parent
0fb057dbcc
commit
4822c19c5d
55
README.md
55
README.md
|
@ -35,26 +35,9 @@ Download the latest Datadog Java Agent:
|
||||||
wget -O dd-java-agent.jar 'https://search.maven.org/remote_content?g=com.datadoghq&a=dd-java-agent&v=LATEST'
|
wget -O dd-java-agent.jar 'https://search.maven.org/remote_content?g=com.datadoghq&a=dd-java-agent&v=LATEST'
|
||||||
```
|
```
|
||||||
|
|
||||||
Then create a file `dd-trace.yaml` anywhere in your application's classpath (or provide the file's path via `-Ddd.trace.configurationFile` when starting the application):
|
Then configure your application using either environment variables or system properties (on the command line via `-D`). See the [config](#configuration) section for details.
|
||||||
|
|
||||||
```yaml
|
**Note:** configuration is also required for [Manual Instrumentation](#manual-instrumentation) with the Datadog Tracer.
|
||||||
# Main service name for the app
|
|
||||||
defaultServiceName: my-java-app
|
|
||||||
|
|
||||||
writer:
|
|
||||||
type: DDAgentWriter # send traces to Datadog Trace Agent; only other option is LoggingWriter
|
|
||||||
host: localhost # host/IP address where Datadog Trace Agent listens
|
|
||||||
port: 8126 # port where Datadog Trace Agent listens
|
|
||||||
|
|
||||||
sampler:
|
|
||||||
type: AllSampler # Collect 100% of traces; only other option is RateSample
|
|
||||||
# rate: 0.5 # if using type: RateSample, uncomment to collect only 50% of traces
|
|
||||||
|
|
||||||
# Skip traces whose root span tag values matches some these regexps; useful if you want to skip health checks traces from your service stats
|
|
||||||
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** this configuration file is also required for [Manual Instrumentation](#manual-instrumentation) with the Datadog Tracer.
|
|
||||||
|
|
||||||
Finally, add the following JVM argument when starting your application—in your IDE, your Maven or gradle application script, or your `java -jar` command:
|
Finally, add the following JVM argument when starting your application—in your IDE, your Maven or gradle application script, or your `java -jar` command:
|
||||||
|
|
||||||
|
@ -64,6 +47,17 @@ Finally, add the following JVM argument when starting your application—in your
|
||||||
|
|
||||||
The Java Agent—once passed to your application—automatically traces requests to the frameworks, application servers, and databases shown below. It does this by using various libraries from [opentracing-contrib](https://github.com/opentracing-contrib). In most cases you don't need to install or configure anything; traces will automatically show up in your Datadog dashboards.
|
The Java Agent—once passed to your application—automatically traces requests to the frameworks, application servers, and databases shown below. It does this by using various libraries from [opentracing-contrib](https://github.com/opentracing-contrib). In most cases you don't need to install or configure anything; traces will automatically show up in your Datadog dashboards.
|
||||||
|
|
||||||
|
#### Configuration
|
||||||
|
|
||||||
|
| Config | System Property | Environment Variable | Default |
|
||||||
|
| ------------- | ---------------- | -------------------- | ------------------ |
|
||||||
|
| service.name | dd.service.name | DD_SERVICE_NAME | `unnamed-java-app` |
|
||||||
|
| writer.type | dd.writer.type | DD_WRITER_TYPE | `DDAgentWriter` |
|
||||||
|
| agent.host | dd.agent.host | DD_AGENT_HOST | `localhost` |
|
||||||
|
| agent.port | dd.agent.port | DD_AGENT_PORT | `8126` |
|
||||||
|
| sampler.type | dd.sampler.type | DD_SAMPLER_TYPE | `AllSampler` |
|
||||||
|
| sampler.rate | dd.sampler.rate | DD_SAMPLER_RATE | `1.0` |
|
||||||
|
|
||||||
#### Application Servers
|
#### Application Servers
|
||||||
|
|
||||||
| Server | Versions | Comments |
|
| Server | Versions | Comments |
|
||||||
|
@ -91,17 +85,6 @@ Also, frameworks like Spring Boot and Dropwizard inherently work because they us
|
||||||
| [MongoDB](https://github.com/opentracing-contrib/java-mongo-driver) | 3.x | Intercepts all the calls from the MongoDB client |
|
| [MongoDB](https://github.com/opentracing-contrib/java-mongo-driver) | 3.x | Intercepts all the calls from the MongoDB client |
|
||||||
| [Cassandra](https://github.com/opentracing-contrib/java-cassandra-driver) | 3.2.x | Intercepts all the calls from the Cassandra client |
|
| [Cassandra](https://github.com/opentracing-contrib/java-cassandra-driver) | 3.2.x | Intercepts all the calls from the Cassandra client |
|
||||||
|
|
||||||
To disable tracing for any of these libraries, list them in `disabledInstrumentations` within `dd-trace.yaml`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
...
|
|
||||||
|
|
||||||
# Disable tracing on these
|
|
||||||
disabledInstrumentations: ["opentracing-apache-httpclient", "opentracing-mongo-driver", "opentracing-web-servlet-filter"]
|
|
||||||
```
|
|
||||||
|
|
||||||
See [this YAML file](dd-java-agent/src/main/resources/dd-trace-supported-framework.yaml) for the proper names of all supported libraries (i.e. the names as you must list them in `disabledInstrumentations`).
|
|
||||||
|
|
||||||
### The `@Trace` Annotation
|
### The `@Trace` Annotation
|
||||||
|
|
||||||
The Java Agent lets you add a `@Trace` annotation to any method to measure its execution time. Setup the [Java Agent](#java-agent-setup) first if you haven't done so.
|
The Java Agent lets you add a `@Trace` annotation to any method to measure its execution time. Setup the [Java Agent](#java-agent-setup) first if you haven't done so.
|
||||||
|
@ -124,12 +107,6 @@ For gradle, add:
|
||||||
compile group: 'com.datadoghq', name: 'dd-trace-annotations', version: {version}
|
compile group: 'com.datadoghq', name: 'dd-trace-annotations', version: {version}
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, in `dd-trace.yaml`, list any applications where you want to use `@Trace`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
enableCustomAnnotationTracingOver: ["com.example.myproject"]`.
|
|
||||||
```
|
|
||||||
|
|
||||||
The Java Agent lets you use `@Trace` not just for `com.example.myproject`, but also for any application whose name _begins_ like that, e.g. `com.example.myproject.foobar`. If you're tempted to list something like `["com", "io"]` to avoid having to fuss with this configuration as you add new projects, be careful; providing `@Trace`-ability to too many applications could hurt your package's build time.
|
The Java Agent lets you use `@Trace` not just for `com.example.myproject`, but also for any application whose name _begins_ like that, e.g. `com.example.myproject.foobar`. If you're tempted to list something like `["com", "io"]` to avoid having to fuss with this configuration as you add new projects, be careful; providing `@Trace`-ability to too many applications could hurt your package's build time.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
@ -193,6 +170,8 @@ compile group: 'io.opentracing', name: 'opentracing-util', version: "0.30.0"
|
||||||
compile group: 'com.datadoghq', name: 'dd-trace', version: "${dd-trace-java.version}"
|
compile group: 'com.datadoghq', name: 'dd-trace', version: "${dd-trace-java.version}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Configure your application using environment variables or system properties as discussed in the [config](#configuration) section.
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
|
|
||||||
Rather than referencing classes directly from `dd-trace` (other than registering `DDTracer`), we strongly suggest using the [OpenTracing API](https://github.com/opentracing/opentracing-java).
|
Rather than referencing classes directly from `dd-trace` (other than registering `DDTracer`), we strongly suggest using the [OpenTracing API](https://github.com/opentracing/opentracing-java).
|
||||||
|
@ -204,7 +183,7 @@ Let's look at a simple example.
|
||||||
class InstrumentedClass {
|
class InstrumentedClass {
|
||||||
|
|
||||||
void method0() {
|
void method0() {
|
||||||
// 1. Make sure dd-trace.yaml is in your resources directory
|
// 1. Configure your application using environment variables or system properties
|
||||||
// 2. If using the Java Agent (-javaagent;/path/to/agent.jar), do not instantiate the GlobalTracer; the Agent instantiates it for you
|
// 2. If using the Java Agent (-javaagent;/path/to/agent.jar), do not instantiate the GlobalTracer; the Agent instantiates it for you
|
||||||
Tracer tracer = io.opentracing.util.GlobalTracer.get();
|
Tracer tracer = io.opentracing.util.GlobalTracer.get();
|
||||||
|
|
||||||
|
@ -261,8 +240,6 @@ public class Application {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`DDTracerFactory` looks for `dd-trace.yaml` in the classpath.
|
|
||||||
|
|
||||||
## Further Reading
|
## Further Reading
|
||||||
|
|
||||||
- Browse the [example applications](dd-trace-examples) in this repository to see Java tracing in action
|
- Browse the [example applications](dd-trace-examples) in this repository to see Java tracing in action
|
||||||
|
|
|
@ -40,7 +40,7 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
jvmArgs "-Ddd.trace.configurationFile=${project.buildDir}/resources/test/dd-trace.yaml"
|
jvmArgs "-Ddd.writer.type=ListWriter", "-Ddd.service.name=java-app"
|
||||||
jvmArgs "-Ddd.slf4j.simpleLogger.defaultLogLevel=debug"
|
jvmArgs "-Ddd.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||||
jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
|
jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
# Service name used if none is provided in the app
|
|
||||||
defaultServiceName: java-app
|
|
||||||
|
|
||||||
# The writer to use.
|
|
||||||
# Could be: LoggingWriter or DDAgentWriter (default)
|
|
||||||
writer:
|
|
||||||
# LoggingWriter: Spans are logged using the application configuration
|
|
||||||
# DDAgentWriter: Spans are forwarding to a Datadog Agent
|
|
||||||
# - Param 'host': the hostname where the DD Agent running (default: localhost)
|
|
||||||
# - Param 'port': the port to reach the DD Agent (default: 8126)
|
|
||||||
type: ListWriter
|
|
||||||
|
|
||||||
# The sampler to use.
|
|
||||||
# Could be: AllSampler (default) or RateSampler
|
|
||||||
sampler:
|
|
||||||
# AllSampler: all spans are reported to the writer
|
|
||||||
# RateSample: only a portion of spans are reported to the writer
|
|
||||||
# - Param 'rate': the portion of spans to keep
|
|
||||||
type: AllSampler
|
|
||||||
# Skip some traces if the root span tag values matches some regexp patterns
|
|
||||||
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
|
|
||||||
|
|
||||||
# Enable custom annotation tracing over a selected set of packages
|
|
||||||
enableCustomAnnotationTracingOver: ["com.datadoghq.agent.test"]
|
|
||||||
|
|
||||||
# Disable some instrumentations
|
|
||||||
# disabledInstrumentations: ["apache http", "mongo", "jetty", "tomcat", ...]
|
|
|
@ -1,23 +0,0 @@
|
||||||
# Service name used if none is provided in the app
|
|
||||||
defaultServiceName: java-app
|
|
||||||
|
|
||||||
# The writer to use.
|
|
||||||
# Could be: LoggingWriter or DDAgentWriter (default)
|
|
||||||
writer:
|
|
||||||
# LoggingWriter: Spans are logged using the application configuration
|
|
||||||
# DDAgentWriter: Spans are forwarding to a Datadog Agent
|
|
||||||
# - Param 'host': the hostname where the DD Agent running (default: localhost)
|
|
||||||
# - Param 'port': the port to reach the DD Agent (default: 8126)
|
|
||||||
type: DDAgentWriter
|
|
||||||
host: localhost
|
|
||||||
port: 8126
|
|
||||||
|
|
||||||
# The sampler to use.
|
|
||||||
# Could be: AllSampler (default) or RateSampler
|
|
||||||
sampler:
|
|
||||||
# AllSampler: all spans are reported to the writer
|
|
||||||
# RateSample: only a portion of spans are reported to the writer
|
|
||||||
# - Param 'rate': the portion of spans to keep
|
|
||||||
type: AllSampler
|
|
||||||
# Skip some traces if the root span tag values matches some regexp patterns
|
|
||||||
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
|
|
|
@ -27,12 +27,12 @@ A valid ``DD_API_KEY`` is required to post collected traces to the Datadog backe
|
||||||
|
|
||||||
Launch the application using the run wrapper you've built during the ``installDist`` step:
|
Launch the application using the run wrapper you've built during the ``installDist`` step:
|
||||||
```bash
|
```bash
|
||||||
JAVA_OPTS=-javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar build/install/dropwizard-mongo-client/bin/dropwizard-mongo-client server
|
JAVA_OPTS="-javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -Ddd.service.name=dropwizard-example" build/install/dropwizard-mongo-client/bin/dropwizard-mongo-client server
|
||||||
```
|
```
|
||||||
|
|
||||||
Or as an executable jar:
|
Or as an executable jar:
|
||||||
```bash
|
```bash
|
||||||
java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -jar build/libs/dropwizard-mongo-client-demo-all.jar server
|
java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -Ddd.service.name=dropwizard-example -jar build/libs/dropwizard-mongo-client-demo-all.jar server
|
||||||
```
|
```
|
||||||
|
|
||||||
``0.2.0-SNAPSHOT`` is an example of what ``{version}`` looks like.
|
``0.2.0-SNAPSHOT`` is an example of what ``{version}`` looks like.
|
||||||
|
|
|
@ -9,6 +9,8 @@ apply from: "${rootDir}/gradle/jacoco.gradle"
|
||||||
version = 'demo'
|
version = 'demo'
|
||||||
description = 'dropwizard-mongo-client'
|
description = 'dropwizard-mongo-client'
|
||||||
mainClassName = 'com.datadoghq.example.dropwizard.BookApplication'
|
mainClassName = 'com.datadoghq.example.dropwizard.BookApplication'
|
||||||
|
applicationDefaultJvmArgs = ["-Ddd.service.name=dropwizard-example"]
|
||||||
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
# Service name used if none is provided in the app
|
|
||||||
defaultServiceName: dropwizard-example
|
|
||||||
|
|
||||||
# The writer to use.
|
|
||||||
# Could be: LoggingWriter or DDAgentWriter (default)
|
|
||||||
writer:
|
|
||||||
# LoggingWriter: Spans are logged using the application configuration
|
|
||||||
# DDAgentWriter: Spans are forwarding to a Datadog Agent
|
|
||||||
# - Param 'host': the hostname where the DD Agent running (default: localhost)
|
|
||||||
# - Param 'port': the port to reach the DD Agent (default: 8126)
|
|
||||||
type: DDAgentWriter
|
|
||||||
host: localhost
|
|
||||||
port: 8126
|
|
||||||
|
|
||||||
# The sampling to use.
|
|
||||||
# Could be: AllSampler (default) or RateSampler
|
|
||||||
sampler:
|
|
||||||
# AllSampler: all spans are reported to the writer
|
|
||||||
# RateSample: only a portion of spans are reported to the writer
|
|
||||||
# - Param 'rate': the portion of spans to keep
|
|
||||||
type: AllSampler
|
|
||||||
# Skip some traces if the root span tag values matches some regexp patterns
|
|
||||||
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
|
|
||||||
|
|
||||||
# Enable custom annotation tracing over a selected set of packages
|
|
||||||
enableCustomAnnotationTracingOver: ["com.datadoghq.example"]
|
|
||||||
|
|
||||||
# Disable some instrumentations
|
|
||||||
# disabledInstrumentations: ["apache http", "mongo", "jetty", "tomcat", ...]
|
|
|
@ -33,7 +33,7 @@ A valid ``DD_API_KEY`` is required to post collected traces to the Datadog backe
|
||||||
|
|
||||||
Launch the application using the run wrapper you've built during the ``installDist`` step:
|
Launch the application using the run wrapper you've built during the ``installDist`` step:
|
||||||
```bash
|
```bash
|
||||||
JAVA_OPTS=-javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar build/install/rest-spark/bin/rest-spark
|
JAVA_OPTS=-javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -Ddd.service.name=rest-spark build/install/rest-spark/bin/rest-spark
|
||||||
```
|
```
|
||||||
|
|
||||||
``0.2.0-SNAPSHOT`` is an example of what ``{version}`` looks like.
|
``0.2.0-SNAPSHOT`` is an example of what ``{version}`` looks like.
|
||||||
|
|
|
@ -9,6 +9,7 @@ apply from: "${rootDir}/gradle/jacoco.gradle"
|
||||||
version = 'demo'
|
version = 'demo'
|
||||||
description = 'rest-spark'
|
description = 'rest-spark'
|
||||||
mainClassName = 'com.datadoghq.example.restspark.SparkApplication'
|
mainClassName = 'com.datadoghq.example.restspark.SparkApplication'
|
||||||
|
applicationDefaultJvmArgs = ["-Ddd.service.name=rest-spark"]
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
defaultServiceName: rest-spark
|
|
||||||
|
|
||||||
writer:
|
|
||||||
type: DDAgentWriter
|
|
||||||
host: localhost
|
|
||||||
port: 8126
|
|
||||||
|
|
||||||
sampler:
|
|
||||||
type: AllSampler
|
|
|
@ -36,7 +36,7 @@ stop it.*
|
||||||
|
|
||||||
Or as an executable jar:
|
Or as an executable jar:
|
||||||
```bash
|
```bash
|
||||||
java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -jar build/libs/spring-boot-jdbc-demo.jar
|
java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -Ddd.service.name=spring-boot-jdbc -jar build/libs/spring-boot-jdbc-demo.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
### Generate traces
|
### Generate traces
|
||||||
|
|
|
@ -22,9 +22,9 @@ bootRepackage {
|
||||||
|
|
||||||
bootRun {
|
bootRun {
|
||||||
if (project.hasProperty('javaagent')) {
|
if (project.hasProperty('javaagent')) {
|
||||||
jvmArgs = ["-javaagent:$javaagent"]
|
jvmArgs = ["-javaagent:$javaagent", "-Ddd.service.name=spring-boot-jdbc"]
|
||||||
} else {
|
} else {
|
||||||
jvmArgs = ["-javaagent:${project(':dd-java-agent').tasks.shadowJar.outputs.files.getFiles().iterator().next()}"]
|
jvmArgs = ["-javaagent:${project(':dd-java-agent').tasks.shadowJar.outputs.files.getFiles().iterator().next()}", "-Ddd.service.name=spring-boot-jdbc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
defaultServiceName: example-spring-boot
|
|
||||||
|
|
||||||
writer:
|
|
||||||
type: DDAgentWriter
|
|
||||||
host: localhost
|
|
||||||
port: 8126
|
|
||||||
|
|
||||||
sampler:
|
|
||||||
type: AllSampler
|
|
|
@ -1,24 +0,0 @@
|
||||||
# Service name used if none is provided in the app
|
|
||||||
defaultServiceName: java-app
|
|
||||||
|
|
||||||
# The writer to use.
|
|
||||||
# Could be: LoggingWritter or DDAgentWriter (default)
|
|
||||||
writer:
|
|
||||||
# LoggingWriter: Spans are logged using the application configuration
|
|
||||||
# DDAgentWriter: Spans are forwarding to a Datadog Agent
|
|
||||||
# - Param 'host': the hostname where the DD Agent running (default: localhost)
|
|
||||||
# - Param 'port': the port to reach the DD Agent (default: 8126)
|
|
||||||
type: DDAgentWriter
|
|
||||||
host: foo
|
|
||||||
port: 123
|
|
||||||
|
|
||||||
# The sampler to use.
|
|
||||||
# Could be: AllSampler (default) or RateSampler
|
|
||||||
sampler:
|
|
||||||
# AllSampler: all spans are reported to the writer
|
|
||||||
# RateSample: only a portion of spans are reported to the writer
|
|
||||||
# - Param 'rate': the portion of spans to keep
|
|
||||||
type: AllSampler
|
|
||||||
|
|
||||||
# Enable custom tracing (annotations)
|
|
||||||
# enableCustomTracing: true
|
|
|
@ -1,23 +0,0 @@
|
||||||
# Service name used if none is provided in the app
|
|
||||||
defaultServiceName: java-app
|
|
||||||
|
|
||||||
# The writer to use.
|
|
||||||
# Could be: LoggingWritter or DDAgentWriter (default)
|
|
||||||
writer:
|
|
||||||
# LoggingWriter: Spans are logged using the application configuration
|
|
||||||
# DDAgentWriter: Spans are forwarding to a Datadog Agent
|
|
||||||
# - Param 'host': the hostname where the DD Agent running (default: localhost)
|
|
||||||
# - Param 'port': the port to reach the DD Agent (default: 8126)
|
|
||||||
type: DDAgentWriter
|
|
||||||
|
|
||||||
# The sampler to use.
|
|
||||||
# Could be: AllSampler (default) or RateSampler
|
|
||||||
sampler:
|
|
||||||
# AllSampler: all spans are reported to the writer
|
|
||||||
# RateSample: only a portion of spans are reported to the writer
|
|
||||||
# - Param 'rate': the portion of spans to keep
|
|
||||||
type: RateSampler
|
|
||||||
rate: 0.4
|
|
||||||
|
|
||||||
# Enable custom tracing (annotations)
|
|
||||||
# enableCustomTracing: true
|
|
|
@ -1 +0,0 @@
|
||||||
defaultServiceName: java-app-default
|
|
|
@ -1,7 +0,0 @@
|
||||||
defaultServiceName: java-app
|
|
||||||
writer:
|
|
||||||
type: DDAgentWriter
|
|
||||||
host: localhost
|
|
||||||
port: 10000
|
|
||||||
sampler:
|
|
||||||
type: AllSampler
|
|
Loading…
Reference in New Issue