From 563171d8f9fd5ded11a1153a8892cc20b170aa3e Mon Sep 17 00:00:00 2001 From: Emanuele Palazzetti Date: Mon, 31 Jul 2017 17:11:03 +0200 Subject: [PATCH] [example] create restspark package to build it with gradlew --- .../rest-spark/rest-spark.gradle | 27 +++++++++++++++---- .../example/restspark}/MongoDriver.java | 2 ++ .../example/restspark/SparkApplication.java} | 4 ++- .../src/main/resources/dd-trace.yaml | 25 ----------------- 4 files changed, 27 insertions(+), 31 deletions(-) rename dd-trace-examples/rest-spark/src/main/java/{ => com/datadoghq/example/restspark}/MongoDriver.java (90%) rename dd-trace-examples/rest-spark/src/main/java/{Hello.java => com/datadoghq/example/restspark/SparkApplication.java} (95%) diff --git a/dd-trace-examples/rest-spark/rest-spark.gradle b/dd-trace-examples/rest-spark/rest-spark.gradle index a203dad0e5..ccf0b5865b 100644 --- a/dd-trace-examples/rest-spark/rest-spark.gradle +++ b/dd-trace-examples/rest-spark/rest-spark.gradle @@ -1,3 +1,7 @@ +plugins { + id "com.github.johnrengelman.shadow" version "2.0.1" +} + apply from: "${rootDir}/gradle/java.gradle" apply from: "${rootDir}/gradle/jacoco.gradle" @@ -8,16 +12,29 @@ sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { - -// compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':dd-trace') + compile 'com.sparkjava:spark-core:2.6.0' compile 'org.mongodb:mongodb-driver:3.4.2' + compile 'io.opentracing:opentracing-api:0.30.0' compile 'io.opentracing:opentracing-util:0.30.0' - compile 'io.opentracing.contrib:opentracing-mongo-driver:0.0.2' + compile 'io.opentracing.contrib:opentracing-mongo-driver:0.0.3' + 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': 'com.datadoghq.example.restspark.SparkApplication' + } +} + +shadowJar { + mergeServiceFiles() +} + +task wrapper(type: Wrapper) { + gradleVersion = '4.0' } diff --git a/dd-trace-examples/rest-spark/src/main/java/MongoDriver.java b/dd-trace-examples/rest-spark/src/main/java/com/datadoghq/example/restspark/MongoDriver.java similarity index 90% rename from dd-trace-examples/rest-spark/src/main/java/MongoDriver.java rename to dd-trace-examples/rest-spark/src/main/java/com/datadoghq/example/restspark/MongoDriver.java index fd0813293f..2cc407dafe 100644 --- a/dd-trace-examples/rest-spark/src/main/java/MongoDriver.java +++ b/dd-trace-examples/rest-spark/src/main/java/com/datadoghq/example/restspark/MongoDriver.java @@ -1,3 +1,5 @@ +package com.datadoghq.example.restspark; + import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoDatabase; diff --git a/dd-trace-examples/rest-spark/src/main/java/Hello.java b/dd-trace-examples/rest-spark/src/main/java/com/datadoghq/example/restspark/SparkApplication.java similarity index 95% rename from dd-trace-examples/rest-spark/src/main/java/Hello.java rename to dd-trace-examples/rest-spark/src/main/java/com/datadoghq/example/restspark/SparkApplication.java index c40bcc76b2..391dcb7eeb 100644 --- a/dd-trace-examples/rest-spark/src/main/java/Hello.java +++ b/dd-trace-examples/rest-spark/src/main/java/com/datadoghq/example/restspark/SparkApplication.java @@ -1,3 +1,5 @@ +package com.datadoghq.example.restspark; + import static spark.Spark.get; import com.mongodb.client.MongoCollection; @@ -7,7 +9,7 @@ import io.opentracing.Tracer; import java.util.Arrays; import org.bson.Document; -public class Hello { +public class SparkApplication { private static MongoDatabase mDatabase; private static Tracer mTracer; diff --git a/dd-trace-examples/rest-spark/src/main/resources/dd-trace.yaml b/dd-trace-examples/rest-spark/src/main/resources/dd-trace.yaml index 825956c281..ff3815988f 100644 --- a/dd-trace-examples/rest-spark/src/main/resources/dd-trace.yaml +++ b/dd-trace-examples/rest-spark/src/main/resources/dd-trace.yaml @@ -1,34 +1,9 @@ -# Main service name for the app defaultServiceName: rest-spark -# 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 trace Agent - # - Param 'host': the hostname where the DD trace Agent is running (default: localhost) - # - Param 'port': the port to reach the DD trace 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.*"} - -# Enable custom tracing (Custom annotations for now) -# enableCustomAnnotationTracingOver: ["io","org","com"] - -# Disable some instrumentations -# disabledInstrumentations: ["opentracing-apache-httpclient", "opentracing-mongo-driver", "opentracing-web-servlet-filter"] - -decorators: - - type: DBComponent - matchingValue: java-mongo - setValue: mongo-spark \ No newline at end of file