You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
38
+
Then configure your application using either environment variables or system properties (on the command line via `-D`). See the [config](#configuration) section for details.
39
39
40
-
```yaml
41
-
# Main service name for the app
42
-
defaultServiceName: my-java-app
43
-
44
-
writer:
45
-
type: DDAgentWriter # send traces to Datadog Trace Agent; only other option is LoggingWriter
46
-
host: localhost # host/IP address where Datadog Trace Agent listens
47
-
port: 8126# port where Datadog Trace Agent listens
48
-
49
-
sampler:
50
-
type: AllSampler # Collect 100% of traces; only other option is RateSample
51
-
# rate: 0.5 # if using type: RateSample, uncomment to collect only 50% of traces
52
-
53
-
# Skip traces whose root span tag values matches some these regexps; useful if you want to skip health checks traces from your service stats
54
-
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
55
-
```
56
-
57
-
**Note:** this configuration file is also required for [Manual Instrumentation](#manual-instrumentation) with the Datadog Tracer.
40
+
**Note:** configuration is also required for [Manual Instrumentation](#manual-instrumentation) with the Datadog Tracer.
58
41
59
42
Finally, add the following JVM argument when starting your application—in your IDE, your Maven or gradle application script, or your `java -jar` command:
60
43
@@ -64,6 +47,17 @@ Finally, add the following JVM argument when starting your application—in your
64
47
65
48
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.
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`).
104
-
105
88
### The `@Trace` Annotation
106
89
107
90
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 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.
Configure your application using environment variables or system properties as discussed in the [config](#configuration) section.
174
+
196
175
#### Examples
197
176
198
177
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.
204
183
classInstrumentedClass {
205
184
206
185
voidmethod0() {
207
-
// 1. Make sure dd-trace.yaml is in your resources directory
186
+
// 1. Configure your application using environment variables or system properties
208
187
// 2. If using the Java Agent (-javaagent;/path/to/agent.jar), do not instantiate the GlobalTracer; the Agent instantiates it for you
Copy file name to clipboardExpand all lines: dd-trace-examples/dropwizard-mongo-client/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,12 +27,12 @@ A valid ``DD_API_KEY`` is required to post collected traces to the Datadog backe
27
27
28
28
Launch the application using the run wrapper you've built during the ``installDist`` step:
29
29
```bash
30
-
JAVA_OPTS=-javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar build/install/dropwizard-mongo-client/bin/dropwizard-mongo-client server
30
+
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
31
31
```
32
32
33
33
Or as an executable jar:
34
34
```bash
35
-
java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -jar build/libs/dropwizard-mongo-client-demo-all.jar server
35
+
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
36
36
```
37
37
38
38
``0.2.0-SNAPSHOT`` is an example of what ``{version}`` looks like.
0 commit comments