[example] create restspark package to build it with gradlew

This commit is contained in:
Emanuele Palazzetti 2017-07-31 17:11:03 +02:00
parent 7667fb6021
commit 563171d8f9
4 changed files with 27 additions and 31 deletions

View File

@ -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'
}

View File

@ -1,3 +1,5 @@
package com.datadoghq.example.restspark;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;

View File

@ -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;

View File

@ -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