opentelemetry-java-instrume.../dd-trace-examples/dropwizard-mongo-client
Tyler Benson 82a9c73c6b Merge pull request #111 from DataDog/tyler/servlet-async
Mark servlet trace filter as async supported
2017-08-24 07:47:15 -07:00
..
gradle/wrapper Don’t exclude the wrapper jar 2017-08-01 15:09:51 -07:00
src/main Mark servlet trace filter as async supported 2017-08-23 16:01:42 -07:00
README.md Update dropwizard and spring boot readmes. 2017-08-23 15:35:55 -07:00
docker-compose.yml [example] update dropwizard example 2017-08-02 16:57:08 +02:00
dropwizard-mongo-client.gradle Update dropwizard and spring boot readmes. 2017-08-23 15:35:55 -07:00
gradlew Add gradlew to examples and update docs 2017-07-21 17:03:31 -07:00
gradlew.bat Add gradlew to examples and update docs 2017-07-21 17:03:31 -07:00

README.md

Dropwizard

This project provides a simple Dropwizard example. This is a supported framework that uses auto-instrumentation for all endpoints. Manual instrumentation has been added as example.

Run the demo

Prerequisites

Be sure to build the project so that the latest version of dd-trace-java components are used. You can build all libraries and examples launching from the dd-trace-java root folder:

./gradlew clean shadowJar installDist

Then you can start all services via Docker:

cd dd-trace-examples/dropwizard-mongo-client
DD_API_KEY=<your_datadog_api_key> docker-compose up -d

A valid DD_API_KEY is required to post collected traces to the Datadog backend.

Run the application

Launch the application using the run wrapper you've built during the installDist step:

JAVA_OPTS=-javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar build/install/dropwizard-mongo-client/bin/dropwizard-mongo-client server

Or as an executable jar:

java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -jar build/libs/dropwizard-mongo-client-demo-all.jar server

0.2.0-SNAPSHOT is an example of what {version} looks like.

Generate traces

With your web browser

Once the application runs. Go to the following url:

Then get back to Datadog and wait a bit to see a trace coming.

Cross process tracing: with the provided TracedClient class

The TracedClient class includes an example of what you can use to do distributed tracing. The class must be auto-instrumented with the Java Agent as above, so that OkHttpClient adds the required headers to continue the tracing cross process.

To run the distributed example, first start the dropwizard app, the mongo db and finally run the main from com.example.helloworld.client.TracedClient

Auto-instrumentation with the dd-trace-agent

The instrumentation is entirely done by the Java Agent which embed a set of rules that automatically recognizes & instruments:

  • The Java servlet filters
  • The Mongo client
  • The @Trace annotation
  • The OkHTTP client (in the TracedClient class)

The Java Agent embeds the OpenTracing Java Agent.