diff --git a/.gitignore b/.gitignore index fe8f4ecce0..007e4fb2cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ ######### target /target -**/target/ **/dependency-reduced-pom.xml # Gradle # @@ -49,11 +48,8 @@ out/ /logs/* /bin /out -*/out /workspace -dd-java-agent/instrumentation/*/out dd-java-agent/benchmark-integration/perf-test-settings.rc -examples/*/out derby.log !dd-java-agent/benchmark/releases/*.jar diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 0a7348ddfd..0000000000 --- a/examples/README.md +++ /dev/null @@ -1,21 +0,0 @@ -## Datadog Java Tracer examples - -The goal of this repository is to offer you some examples about how to instrument your code -using the OpenTracing API and the DD Tracer. - -![](https://datadog-live.imgix.net/img/datadog_logo_share_tt.png) - -Here are the examples -* [Dropwizard (Jax-Rs) + Mongo database + HTTP Client](dropwizard-mongo-client/README.md) -* [Spring-boot + MySQL JDBC database + Redis (Jedis client)](spring-boot-jdbc-redis/README.md) -* [Instrumenting using a Java Agent](javaagent/README.md) - - -## Prerequisites - -In order to run the demos, you have to do something before: - -* Get the latest lib of the DD-Tracer and push it to the lib directory -* Make sure you have a running Datadog Agent on the local port 8126 (default one) -* In the Datadog agent configuration, set APM to true (and restart it) -* Maven diff --git a/examples/dropwizard-mongo-client/README.md b/examples/dropwizard-mongo-client/README.md deleted file mode 100644 index bd672538fb..0000000000 --- a/examples/dropwizard-mongo-client/README.md +++ /dev/null @@ -1,72 +0,0 @@ -## Dropwizard - -This project provides a simple [Dropwizard][1] example. This is a supported framework that uses -auto-instrumentation for all endpoints. Manual instrumentation has been added as example. - -[1]: http://www.dropwizard.io/ - -### 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: -```bash -./gradlew clean shadowJar installDist -``` - -Then you can start all services via Docker: -```bash -cd examples/dropwizard-mongo-client -DD_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: -```bash -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: -```bash -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. - -### Generate traces - -#### With your web browser - -Once the application runs. Go to the following url: - -* [http://localhost:8080/demo/add?title=some-book-title&isbn=1234&page=42][1] -* [http://localhost:8080/demo/][2] - -[1]: http://localhost:8080/demo/add?title=some-book-title&isbn=1234&page=42 -[2]: http://localhost:8080/demo/ - -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](https://github.com/opentracing-contrib/java-agent). diff --git a/examples/dropwizard-mongo-client/docker-compose.yml b/examples/dropwizard-mongo-client/docker-compose.yml deleted file mode 100644 index 2c25cfab97..0000000000 --- a/examples/dropwizard-mongo-client/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -mongo: - image: mongo:3.2 - ports: - - "127.0.0.1:27017:27017" - -ddagent: - image: datadog/docker-dd-agent - environment: - - DD_BIND_HOST=0.0.0.0 - - DD_API_KEY - ports: - - "127.0.0.1:8126:8126" diff --git a/examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle b/examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle deleted file mode 100644 index 8bca2c85eb..0000000000 --- a/examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle +++ /dev/null @@ -1,41 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "2.0.4" -} - -apply plugin: 'application' -apply from: "${rootDir}/gradle/java.gradle" - -version = 'demo' -description = 'dropwizard-mongo-client' -mainClassName = 'datadog.example.dropwizard.BookApplication' -applicationDefaultJvmArgs = ["-Ddd.service.name=dropwizard-example"] - - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -dependencies { - compile project(':dd-trace-ot') - compile project(':dd-trace-api') - - compile deps.opentracing - - compile group: 'io.dropwizard', name: 'dropwizard-core', version: '0.9.2' - compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2' - compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.7.0' -} - -jar { - manifest { - attributes 'Main-Class': 'datadog.example.dropwizard.BookApplication' - } -} - -shadowJar { - mergeServiceFiles() -} - - -task wrapper(type: Wrapper) { - gradleVersion = gradleWrapperVersion -} diff --git a/examples/dropwizard-mongo-client/gradle/wrapper/gradle-wrapper.jar b/examples/dropwizard-mongo-client/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a..0000000000 Binary files a/examples/dropwizard-mongo-client/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/dropwizard-mongo-client/gradle/wrapper/gradle-wrapper.properties b/examples/dropwizard-mongo-client/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 16d28051c9..0000000000 --- a/examples/dropwizard-mongo-client/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/dropwizard-mongo-client/gradlew b/examples/dropwizard-mongo-client/gradlew deleted file mode 100755 index cccdd3d517..0000000000 --- a/examples/dropwizard-mongo-client/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/examples/dropwizard-mongo-client/gradlew.bat b/examples/dropwizard-mongo-client/gradlew.bat deleted file mode 100644 index e95643d6a2..0000000000 --- a/examples/dropwizard-mongo-client/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/BookApplication.java b/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/BookApplication.java deleted file mode 100644 index 8602784b2c..0000000000 --- a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/BookApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -package datadog.example.dropwizard; - -import datadog.example.dropwizard.resources.SimpleCrudResource; -import io.dropwizard.Application; -import io.dropwizard.Configuration; -import io.dropwizard.setup.Bootstrap; -import io.dropwizard.setup.Environment; - -public class BookApplication extends Application { - public static void main(final String[] args) throws Exception { - new BookApplication().run(args); - } - - @Override - public String getName() { - return "hello-world"; - } - - @Override - public void initialize(final Bootstrap bootstrap) { - // nothing to do yet - } - - @Override - public void run(final Configuration configuration, final Environment environment) { - - environment.jersey().register(new SimpleCrudResource()); - } -} diff --git a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/api/Book.java b/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/api/Book.java deleted file mode 100644 index 1a4d1f7da0..0000000000 --- a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/api/Book.java +++ /dev/null @@ -1,38 +0,0 @@ -package datadog.example.dropwizard.api; - -import com.fasterxml.jackson.annotation.JsonProperty; -import org.bson.Document; - -public class Book { - - private final String title; - private final int numberPages; - private final String isbnCode; - - public Book(final String isbnCode, final String title, final int numberPages) { - this.title = title; - this.numberPages = numberPages; - this.isbnCode = isbnCode; - } - - public Book(final Document d) { - this(d.getString("isbn"), d.getString("title"), d.getInteger("page").intValue()); - } - - @JsonProperty("ISBN") - public String getIsbnCode() { - return isbnCode; - } - - public String getTitle() { - return title; - } - - public int getNumberPages() { - return numberPages; - } - - public Document toDocument() { - return new Document("isbn", isbnCode).append("title", title).append("page", numberPages); - } -} diff --git a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/client/TracedClient.java b/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/client/TracedClient.java deleted file mode 100644 index 2b05b65bf1..0000000000 --- a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/client/TracedClient.java +++ /dev/null @@ -1,38 +0,0 @@ -package datadog.example.dropwizard.client; - -import datadog.trace.api.DDTags; -import datadog.trace.api.Trace; -import io.opentracing.Scope; -import io.opentracing.Tracer; -import io.opentracing.util.GlobalTracer; -import java.io.IOException; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; - -/** - * This class is just a HTTP Client with a trace started. The spanId and the traceId are forwarded - * through HTTP headers The server is able to reconstruct the parent span via extracted headers The - * full trace will be reconstruct via the APM - */ -public class TracedClient { - - public static void main(final String[] args) throws Exception { - executeCall(); - System.out.println("After execute"); - } - - @Trace - private static void executeCall() throws IOException { - final Tracer tracer = GlobalTracer.get(); - final Scope scope = tracer.scopeManager().active(); - scope.span().setTag(DDTags.SERVICE_NAME, "http.client"); - - final OkHttpClient client = new OkHttpClient().newBuilder().build(); - final Request request = new Request.Builder().url("http://localhost:8080/demo/").build(); - final Response response = client.newCall(request).execute(); - if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); - - System.out.println(response.body().string()); - } -} diff --git a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/resources/SimpleCrudResource.java b/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/resources/SimpleCrudResource.java deleted file mode 100644 index ed1061cde2..0000000000 --- a/examples/dropwizard-mongo-client/src/main/java/datadog/example/dropwizard/resources/SimpleCrudResource.java +++ /dev/null @@ -1,141 +0,0 @@ -package datadog.example.dropwizard.resources; - -import com.google.common.base.Optional; -import com.mongodb.MongoClient; -import com.mongodb.client.MongoCursor; -import com.mongodb.client.MongoDatabase; -import datadog.example.dropwizard.api.Book; -import datadog.trace.api.Trace; -import io.opentracing.Scope; -import io.opentracing.util.GlobalTracer; -import java.util.ArrayList; -import java.util.List; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.container.AsyncResponse; -import javax.ws.rs.container.Suspended; -import javax.ws.rs.core.MediaType; -import org.bson.Document; - -@Path("/demo") -@Produces(MediaType.APPLICATION_JSON) -public class SimpleCrudResource { - - private final MongoClient client; - private final MongoDatabase db; - private static final String HOSTNAME = "localhost"; - private static final String DATABASE = "demo"; - private static final java.lang.String COLLECTION = "books"; - - public SimpleCrudResource() { - - // Init the client - client = new MongoClient(HOSTNAME); - - // For this example, start from a fresh DB - try { - client.dropDatabase(DATABASE); - } catch (final Exception e) { - // do nothing here - } - - // Init the connection to the collection - db = client.getDatabase(DATABASE); - db.createCollection(COLLECTION); - } - - /** - * Add a book to the DB - * - * @return The status of the save - * @throws InterruptedException - */ - @GET - @Path("/add") - public String addBook( - @QueryParam("isbn") final Optional isbn, - @QueryParam("title") final Optional title, - @QueryParam("page") final Optional page) - throws InterruptedException { - - // The methodDB is traced (see below), this will be produced a new child span - beforeDB(); - - if (!isbn.isPresent()) { - throw new IllegalArgumentException("ISBN should not be null"); - } - - final Book book = new Book(isbn.get(), title.or("Missing title"), page.or(0)); - - db.getCollection(COLLECTION).insertOne(book.toDocument()); - return "Book saved!"; - } - - /** - * List all books present in the DB - * - * @return list of Books - * @throws InterruptedException - */ - @GET - public List getBooks() throws InterruptedException { - - // The methodDB is traced (see below), this will be produced a new childre span - beforeDB(); - - final List books = new ArrayList<>(); - try (MongoCursor cursor = db.getCollection(COLLECTION).find().iterator()) { - while (cursor.hasNext()) { - books.add(new Book(cursor.next())); - } - } - - // The methodDB is traced (see below), this will be produced a new child span - afterDB(); - - return books; - } - - @GET - @Path("/async") - public void async(@Suspended final AsyncResponse response) { - // not actually async, but useful for testing that codepath. - response.resume("Returned from async"); - } - - /** - * The beforeDB is traced using the annotation @Trace with a custom operationName and a custom - * tag. - * - * @throws InterruptedException - */ - @Trace(operationName = "database.before") - public void beforeDB() throws InterruptedException { - final Scope scope = GlobalTracer.get().scopeManager().active(); - if (scope != null) { - scope.span().setTag("status", "started"); - Thread.sleep(10); - } - } - - /** - * The afterDB is traced using the annotation @Trace with a custom operationName and a custom tag. - * - * @throws InterruptedException - */ - @Trace(operationName = "database.after") - public void afterDB() throws InterruptedException { - final Scope scope = GlobalTracer.get().scopeManager().active(); - if (scope != null) { - scope.span().setTag("status", "started"); - Thread.sleep(10); - } - } - - /** Flush resources */ - public void close() { - client.close(); - } -} diff --git a/examples/dropwizard-mongo-client/src/main/resources/configuration.yaml b/examples/dropwizard-mongo-client/src/main/resources/configuration.yaml deleted file mode 100644 index 295673f037..0000000000 --- a/examples/dropwizard-mongo-client/src/main/resources/configuration.yaml +++ /dev/null @@ -1,5 +0,0 @@ -logging: - level: INFO - loggers: - "datadog.trace": DEBUG - "io.opentracing": DEBUG diff --git a/examples/rest-spark/README.md b/examples/rest-spark/README.md deleted file mode 100644 index 610c6210e7..0000000000 --- a/examples/rest-spark/README.md +++ /dev/null @@ -1,62 +0,0 @@ -## REST Spark - -This project provides a simple REST API using the [Spark web framework][1]. 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. - -[1]: http://sparkjava.com/ - -### 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: -```bash -./gradlew clean shadowJar -``` - -Then you can prepare the distributable version of the ``rest-spark`` as follows: -```bash -cd examples/rest-spark -./gradlew installDist -``` - -Then you can start all services via Docker: -```bash -DD_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: -```bash -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: - -* [http://localhost:4567/key/something][2] -* [http://localhost:4567/key/something_else][3] - -Then get back to Datadog and wait a bit to see a trace coming. - -[2]: http://localhost:4567/key/something -[3]: http://localhost:4567/key/something_else - -#### 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](https://github.com/opentracing-contrib/java-agent). diff --git a/examples/rest-spark/docker-compose.yml b/examples/rest-spark/docker-compose.yml deleted file mode 100644 index 2c25cfab97..0000000000 --- a/examples/rest-spark/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -mongo: - image: mongo:3.2 - ports: - - "127.0.0.1:27017:27017" - -ddagent: - image: datadog/docker-dd-agent - environment: - - DD_BIND_HOST=0.0.0.0 - - DD_API_KEY - ports: - - "127.0.0.1:8126:8126" diff --git a/examples/rest-spark/gradle/wrapper/gradle-wrapper.jar b/examples/rest-spark/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a..0000000000 Binary files a/examples/rest-spark/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/rest-spark/gradle/wrapper/gradle-wrapper.properties b/examples/rest-spark/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 16d28051c9..0000000000 --- a/examples/rest-spark/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/rest-spark/gradlew b/examples/rest-spark/gradlew deleted file mode 100755 index cccdd3d517..0000000000 --- a/examples/rest-spark/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/examples/rest-spark/gradlew.bat b/examples/rest-spark/gradlew.bat deleted file mode 100644 index e95643d6a2..0000000000 --- a/examples/rest-spark/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/rest-spark/rest-spark.gradle b/examples/rest-spark/rest-spark.gradle deleted file mode 100644 index 51f1df9525..0000000000 --- a/examples/rest-spark/rest-spark.gradle +++ /dev/null @@ -1,40 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "2.0.4" -} - -apply plugin: 'application' -apply from: "${rootDir}/gradle/java.gradle" - -version = 'demo' -description = 'rest-spark' -mainClassName = 'datadog.example.restspark.SparkApplication' -applicationDefaultJvmArgs = ["-Ddd.service.name=rest-spark"] - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -dependencies { - compile project(':dd-trace-ot') - - compile 'com.sparkjava:spark-core:2.6.0' - compile 'org.mongodb:mongodb-driver:3.4.2' - - compile deps.opentracing - - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' -} - -jar { - manifest { - attributes 'Main-Class': 'datadog.example.restspark.SparkApplication' - } -} - -shadowJar { - mergeServiceFiles() -} - -task wrapper(type: Wrapper) { - gradleVersion = gradleWrapperVersion -} diff --git a/examples/rest-spark/src/main/java/datadog/example/restspark/MongoDriver.java b/examples/rest-spark/src/main/java/datadog/example/restspark/MongoDriver.java deleted file mode 100644 index 3e50bad460..0000000000 --- a/examples/rest-spark/src/main/java/datadog/example/restspark/MongoDriver.java +++ /dev/null @@ -1,14 +0,0 @@ -package datadog.example.restspark; - -import com.mongodb.MongoClient; -import com.mongodb.MongoClientURI; -import com.mongodb.client.MongoDatabase; - -public class MongoDriver { - - public static MongoDatabase getDatabase(final String dbName) { - final MongoClientURI connectionString = new MongoClientURI("mongodb://localhost:27017"); - final MongoClient mongoClient = new MongoClient(connectionString); - return mongoClient.getDatabase(dbName); - } -} diff --git a/examples/rest-spark/src/main/java/datadog/example/restspark/SparkApplication.java b/examples/rest-spark/src/main/java/datadog/example/restspark/SparkApplication.java deleted file mode 100644 index 145bbe1702..0000000000 --- a/examples/rest-spark/src/main/java/datadog/example/restspark/SparkApplication.java +++ /dev/null @@ -1,64 +0,0 @@ -package datadog.example.restspark; - -import static spark.Spark.get; - -import com.mongodb.client.MongoCollection; -import com.mongodb.client.MongoDatabase; -import io.opentracing.Scope; -import io.opentracing.Tracer; -import java.util.Arrays; -import org.bson.Document; - -public class SparkApplication { - private static MongoDatabase mDatabase; - private static Tracer mTracer; - - public static void main(final String[] args) { - // Get the global tracer - mTracer = io.opentracing.util.GlobalTracer.get(); - - // initialize the Mongo database - mDatabase = MongoDriver.getDatabase("rest_spark"); - - // our routes - get("/healthz", (req, res) -> "OK!"); - get( - "/key/:id", - (req, res) -> { - try (Scope scope = mTracer.buildSpan("spark.request").startActive(true)) { - final String id = req.params(":id"); - - // create a collection - final Document doc = - new Document("name", "MongoDB") - .append("type", "database") - .append("identifier", id) - .append("versions", Arrays.asList("v3.2", "v3.0", "v2.6")) - .append("info", new Document("x", 203).append("y", 102)); - - final MongoCollection collection = mDatabase.getCollection("calls"); - collection.insertOne(doc); - - // write the count somewhere - System.out.println(collection.count()); - - // add some metadata to the request Span - scope.span().setTag("http.status_code", res.status()); - scope.span().setTag("http.url", req.url()); - - return "Stored!"; - } - }); - get( - "/users/:id", - (req, res) -> { - try (Scope scope = mTracer.buildSpan("spark.request").startActive(true)) { - // this endpoint tests the 404 decorator - res.status(404); - scope.span().setTag("http.status_code", res.status()); - scope.span().setTag("http.url", req.url()); - } - return "404"; - }); - } -} diff --git a/examples/rest-spark/src/main/resources/configuration.yaml b/examples/rest-spark/src/main/resources/configuration.yaml deleted file mode 100644 index 295673f037..0000000000 --- a/examples/rest-spark/src/main/resources/configuration.yaml +++ /dev/null @@ -1,5 +0,0 @@ -logging: - level: INFO - loggers: - "datadog.trace": DEBUG - "io.opentracing": DEBUG diff --git a/examples/spring-boot-jdbc-redis/README.md b/examples/spring-boot-jdbc-redis/README.md deleted file mode 100644 index 065f1cc18a..0000000000 --- a/examples/spring-boot-jdbc-redis/README.md +++ /dev/null @@ -1,61 +0,0 @@ -## Spring-boot - -This project provides a simple API using [Spring Boot][1]. The framework is supported and auto-instrumentation is used -to trace the endpoints. - -[1]: https://projects.spring.io/spring-boot/ - -### 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: -```bash -./gradlew clean shadowJar bootRepackage -``` - -Then you can launch the Datadog agent and a Redis instance as follows: -```bash -cd examples/spring-boot-jdbc-redis -DD_API_KEY= docker-compose up -d -``` - -A valid ``DD_API_KEY`` is required to post collected traces to the Datadog backend. - -#### Run the application - -To launch the application, just: -```bash -./gradlew bootRun -``` - -*Note: The ``bootRun`` Gradle command appends automatically the ``-javaagent`` argument, so that you don't need to specify -the path of the Java Agent. Gradle executes the ``:examples:spring-boot-jdbc-redis:bootRun`` task until you -stop it.* - -Or as an executable jar: -```bash -java -javaagent:../../dd-java-agent/build/libs/dd-java-agent-{version}.jar -Ddd.service.name=spring-boot-jdbc-redis -jar build/libs/spring-boot-jdbc-redis-demo.jar -``` - -### Generate traces - -Once the Gradle task is running. Go to the following urls: - -* [http://localhost:8080/user/add?name=foo&email=bar](http://localhost:8080/user/add?name=foo&email=bar) -* [http://localhost:8080/user/all](http://localhost:8080/user/all) -* [http://localhost:8080/user/all](http://localhost:8080/user/random) - -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 datadog agent which embed a set of rules that automatically recognizes & -instruments: - -- The java servlet filters -- The JDBC driver -- The Jedis Redis client - -The Java Agent embeds the [OpenTracing Java Agent](https://github.com/opentracing-contrib/java-agent). diff --git a/examples/spring-boot-jdbc-redis/docker-compose.yml b/examples/spring-boot-jdbc-redis/docker-compose.yml deleted file mode 100644 index 2ef28b663c..0000000000 --- a/examples/spring-boot-jdbc-redis/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -ddagent: - image: datadog/docker-dd-agent - environment: - - DD_BIND_HOST=0.0.0.0 - - DD_API_KEY - ports: - - "127.0.0.1:8126:8126" -redis: - image: redis - ports: - - "127.0.0.1:6379:6379" diff --git a/examples/spring-boot-jdbc-redis/gradle/wrapper/gradle-wrapper.jar b/examples/spring-boot-jdbc-redis/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a..0000000000 Binary files a/examples/spring-boot-jdbc-redis/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/spring-boot-jdbc-redis/gradle/wrapper/gradle-wrapper.properties b/examples/spring-boot-jdbc-redis/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 16d28051c9..0000000000 --- a/examples/spring-boot-jdbc-redis/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/spring-boot-jdbc-redis/gradlew b/examples/spring-boot-jdbc-redis/gradlew deleted file mode 100755 index cccdd3d517..0000000000 --- a/examples/spring-boot-jdbc-redis/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/examples/spring-boot-jdbc-redis/gradlew.bat b/examples/spring-boot-jdbc-redis/gradlew.bat deleted file mode 100644 index e95643d6a2..0000000000 --- a/examples/spring-boot-jdbc-redis/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/examples/spring-boot-jdbc-redis/spring-boot-jdbc-redis.gradle b/examples/spring-boot-jdbc-redis/spring-boot-jdbc-redis.gradle deleted file mode 100644 index fd10a34660..0000000000 --- a/examples/spring-boot-jdbc-redis/spring-boot-jdbc-redis.gradle +++ /dev/null @@ -1,34 +0,0 @@ -plugins { - id 'org.springframework.boot' version '1.5.10.RELEASE' -} - -apply from: "${rootDir}/gradle/java.gradle" - -version = 'demo' -description = 'spring-boot-jdbc-redis' - -dependencies { - compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3' - - compile group: 'com.h2database', name: 'h2', version: '1.4.196' - compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.10.RELEASE' - compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.5.10.RELEASE' - compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis', version: '1.5.10.RELEASE' - -} - -bootRepackage { - mainClass = 'datadog.examples.Application' -} - -bootRun { - if (project.hasProperty('javaagent')) { - jvmArgs = ["-javaagent:$javaagent", "-Ddd.service.name=spring-boot-jdbc-redis"] - } else { - jvmArgs = ["-javaagent:${project(':dd-java-agent').tasks.shadowJar.outputs.files.getFiles().iterator().next()}", "-Ddd.service.name=spring-boot-jdbc-redis"] - } -} - -task wrapper(type: Wrapper) { - gradleVersion = gradleWrapperVersion -} diff --git a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/Application.java b/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/Application.java deleted file mode 100644 index fc172fef99..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/Application.java +++ /dev/null @@ -1,12 +0,0 @@ -package datadog.examples; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(final String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/ApplicationConfig.java b/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/ApplicationConfig.java deleted file mode 100644 index a7ed055465..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/ApplicationConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package datadog.examples; - -import org.apache.http.impl.client.HttpClientBuilder; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@EnableAutoConfiguration -public class ApplicationConfig extends WebMvcConfigurerAdapter { - - @Bean - public HttpClientBuilder getHttpClientBuilder() { - return HttpClientBuilder.create(); - } -} diff --git a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/entities/User.java b/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/entities/User.java deleted file mode 100644 index 420978c92b..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/entities/User.java +++ /dev/null @@ -1,42 +0,0 @@ -package datadog.examples.entities; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity // This tells Hibernate to make a table out of this class -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Integer id; - - private String name; - - private String email; - - public Integer getId() { - return id; - } - - public void setId(final Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } -} diff --git a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/entities/UserRepository.java b/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/entities/UserRepository.java deleted file mode 100644 index 6ebf1900c3..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/entities/UserRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package datadog.examples.entities; - -import org.springframework.data.repository.CrudRepository; - -// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository -// CRUD refers Create, Read, Update, Delete - -public interface UserRepository extends CrudRepository {} diff --git a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/resources/DBResource.java b/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/resources/DBResource.java deleted file mode 100644 index 93c4cc0759..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/resources/DBResource.java +++ /dev/null @@ -1,67 +0,0 @@ -package datadog.examples.resources; - -import datadog.examples.entities.User; -import datadog.examples.entities.UserRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.data.redis.core.ValueOperations; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller // This means that this class is a Controller -@RequestMapping(path = "/user") // This means URL's start with /demo (after Application path) -public class DBResource { - - @Autowired // This means to get the bean called userRepository - // Which is auto-generated by Spring, we will use it to handle the data - private UserRepository userRepository; - - private ValueOperations ops; - - public DBResource(@Autowired StringRedisTemplate template) { - this.ops = template.opsForValue(); - } - - @GetMapping(path = "/add") // Map ONLY GET Requests - public @ResponseBody String addNewUser( - @RequestParam final String name, @RequestParam final String email) { - - // @ResponseBody means the returned String is the response, not a view name - // @RequestParam means it is a parameter from the GET or POST request - - final User n = new User(); - n.setName(name); - n.setEmail(email); - userRepository.save(n); - - // Also save to redis as key/value - ops.set(name, email); - - return "Saved"; - } - - @GetMapping(path = "/all") - public @ResponseBody Iterable getAllUsers() { - // This returns a JSON or XML with the users - return userRepository.findAll(); - } - - @GetMapping(path = "/get") - public @ResponseBody User getUser(@RequestParam final int id) { - // This returns a JSON or XML with the user - return userRepository.findOne(id); - } - - @GetMapping(path = "/getredis") - public @ResponseBody String getUserRedis(@RequestParam final String name) { - return ops.get(name); - } - - @GetMapping(path = "/random") - public @ResponseBody String flushRedis() { - return ops.getOperations().randomKey(); - } -} diff --git a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/resources/HomeResource.java b/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/resources/HomeResource.java deleted file mode 100644 index c4fca29ccb..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/java/datadog/examples/resources/HomeResource.java +++ /dev/null @@ -1,29 +0,0 @@ -package datadog.examples.resources; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/") -public class HomeResource { - - @RequestMapping(method = RequestMethod.GET) - public String test() { - - final StringBuilder template = new StringBuilder(); - - template.append("Demo links"); - template.append(""); - - return template.toString(); - } -} diff --git a/examples/spring-boot-jdbc-redis/src/main/resources/application.properties b/examples/spring-boot-jdbc-redis/src/main/resources/application.properties deleted file mode 100644 index 57104fffac..0000000000 --- a/examples/spring-boot-jdbc-redis/src/main/resources/application.properties +++ /dev/null @@ -1,7 +0,0 @@ -# you must set the following so that OpenTracing traced driver is used -spring.datasource.driver-class-name=org.h2.Driver -spring.datasource.url=jdbc:h2:mem:spring-test;DB_CLOSE_ON_EXIT=FALSE - -# set the logging level -logging.level.root=INFO -logging.level.datadog.trace=DEBUG diff --git a/settings.gradle b/settings.gradle index 94a6a877c2..f9ad56f062 100644 --- a/settings.gradle +++ b/settings.gradle @@ -49,11 +49,6 @@ include ':dd-java-agent:benchmark' include ':dd-java-agent:benchmark-integration' include ':dd-java-agent:benchmark-integration:jetty-perftest' -// examples -include ':examples:dropwizard-mongo-client' -include ':examples:spring-boot-jdbc-redis' -include ':examples:rest-spark' - def setBuildFile(project) { project.buildFileName = "${project.name}.gradle" project.children.each {