opentelemetry-java-instrume.../examples/rest-spark
Tyler Benson 9a52303376 Apply jacoco to every java project
Some projects have ignores/whitelists, but generally coverage is pretty high.

AFAIK, this doesn’t really capture instrumentation test coverage though.
2018-05-04 16:23:32 +10:00
..
gradle/wrapper Upgrade gradle version. 2018-04-27 12:42:51 +10:00
src/main Changes required for supporting OT 0.31.0 2018-01-16 09:52:28 -05:00
README.md Lots of renaming 2018-01-09 10:02:06 +10:00
docker-compose.yml Lots of renaming 2018-01-09 10:02:06 +10:00
gradlew Lots of renaming 2018-01-09 10:02:06 +10:00
gradlew.bat Lots of renaming 2018-01-09 10:02:06 +10:00
rest-spark.gradle Apply jacoco to every java project 2018-05-04 16:23:32 +10:00

README.md

REST Spark

This project provides a simple REST API using the Spark web framework. Even if the framework is not directly supported, manual instrumentation is used to trace one of the endpoints. A MongoClient is traced so that Mongo calls are part of the Spark trace.

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

Then you can prepare the distributable version of the rest-spark as follows:

cd examples/rest-spark
./gradlew installDist

Then you can start all services via Docker:

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 -Ddd.service.name=rest-spark build/install/rest-spark/bin/rest-spark

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.

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 Mongo client

The Java Agent embeds the OpenTracing Java Agent.