|
@@ -1,52 +1,114 @@
|
|
|
+plugins {
|
|
|
+ id "java"
|
|
|
+
|
|
|
+ /*
|
|
|
+ Instrumentation agent extension mechanism expects a single jar containing everything required
|
|
|
+ for your extension. This also includes any external libraries that your extension uses and
|
|
|
+ cannot access from application classpath (see comment below about `javax.servlet-api` dependency).
|
|
|
+
|
|
|
+ Thus we use Shadow Gradle plugin to package our classes and all required runtime dependencies
|
|
|
+ into a single jar.
|
|
|
+ See https://imperceptiblethoughts.com/shadow/ for more details about Shadow plugin.
|
|
|
+ */
|
|
|
+ id "com.github.johnrengelman.shadow" version "6.1.0"
|
|
|
+}
|
|
|
+
|
|
|
group 'io.opentelemetry.example'
|
|
|
-version '1.0-SNAPSHOT'
|
|
|
-
|
|
|
-subprojects {
|
|
|
- version = rootProject.version
|
|
|
-
|
|
|
- apply plugin: "java"
|
|
|
-
|
|
|
- ext {
|
|
|
- versions = [
|
|
|
- opentelemetry : "1.2.0",
|
|
|
- opentelemetryJavaagent: "1.3.0-SNAPSHOT",
|
|
|
- bytebuddy : "1.10.18",
|
|
|
- guava : "30.1-jre"
|
|
|
- ]
|
|
|
- versions.opentelemetryAlpha = "${versions.opentelemetry}-alpha"
|
|
|
- versions.opentelemetryJavaagentAlpha = "1.3.0-alpha-SNAPSHOT"
|
|
|
-
|
|
|
- deps = [
|
|
|
- bytebuddy : dependencies.create(group: 'net.bytebuddy', name: 'byte-buddy', version: versions.bytebuddy),
|
|
|
- bytebuddyagent : dependencies.create(group: 'net.bytebuddy', name: 'byte-buddy-agent', version: versions.bytebuddy),
|
|
|
- autoservice : [
|
|
|
- dependencies.create(group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc7'),
|
|
|
- dependencies.create(group: 'com.google.auto', name: 'auto-common', version: '0.8'),
|
|
|
- dependencies.create(group: 'com.google.guava', name: 'guava', version: "${versions.guava}"),
|
|
|
- ],
|
|
|
- autoValueAnnotations: "com.google.auto.value:auto-value-annotations:${versions.autoValue}",
|
|
|
- ]
|
|
|
- }
|
|
|
+version '1.0'
|
|
|
|
|
|
- repositories {
|
|
|
- // needed because relying on locally built SNAPSHOT versions above for now
|
|
|
- mavenLocal()
|
|
|
- mavenCentral()
|
|
|
- }
|
|
|
+ext {
|
|
|
+ versions = [
|
|
|
+ opentelemetry : "1.2.0",
|
|
|
+ opentelemetryAlpha : "1.2.0-alpha",
|
|
|
+ opentelemetryJavaagent : "1.3.0-SNAPSHOT",
|
|
|
+ opentelemetryJavaagentAlpha: "1.3.0-alpha-SNAPSHOT",
|
|
|
+ ]
|
|
|
|
|
|
- dependencies {
|
|
|
- testImplementation("org.mockito:mockito-core:3.3.3")
|
|
|
- testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
|
|
|
- testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
|
|
|
+ deps = [
|
|
|
+ autoservice: dependencies.create(group: 'com.google.auto.service', name: 'auto-service', version: '1.0')
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+repositories {
|
|
|
+ mavenCentral()
|
|
|
+ maven {
|
|
|
+ url = uri("https://oss.sonatype.org/content/repositories/snapshots")
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- tasks {
|
|
|
- test {
|
|
|
- useJUnitPlatform()
|
|
|
- }
|
|
|
+configurations {
|
|
|
+ /*
|
|
|
+ We create a separate gradle configuration to grab a published Otel instrumentation agent.
|
|
|
+ We don't need the agent during development of this extension module.
|
|
|
+ This agent is used only during integration test.
|
|
|
+ */
|
|
|
+ otel
|
|
|
+}
|
|
|
+
|
|
|
+dependencies {
|
|
|
+ /*
|
|
|
+ Interfaces and SPIs that we implement. We use `compileOnly` dependency because during
|
|
|
+ runtime all neccessary classes are provided by javaagent itself.
|
|
|
+ */
|
|
|
+ compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${versions.opentelemetryAlpha}")
|
|
|
+ compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-api:${versions.opentelemetryJavaagentAlpha}")
|
|
|
+ compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${versions.opentelemetryJavaagentAlpha}")
|
|
|
+
|
|
|
+ //Provides @AutoService annotation that makes registration of our SPI implementations much easier
|
|
|
+ compileOnly deps.autoservice
|
|
|
+ annotationProcessor deps.autoservice
|
|
|
|
|
|
- compileJava {
|
|
|
- options.release.set(11)
|
|
|
+ /*
|
|
|
+ Used by our demo instrumentation module to reference classes of the target instrumented library.
|
|
|
+ We again use `compileOnly` here because during runtime these classes are provided by the
|
|
|
+ actual application that we instrument.
|
|
|
+
|
|
|
+ NB! Only Advice (and "helper") classes of instrumentation modules can access classes from application classpath.
|
|
|
+ See https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/writing-instrumentation-module.md#advice-classes
|
|
|
+ */
|
|
|
+ compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
|
|
|
+
|
|
|
+ /*
|
|
|
+ This dependency is required for DemoSpanProcessor both during compile and runtime.
|
|
|
+ Only dependencies added to `implementation` configuration will be picked up by Shadow plugin
|
|
|
+ and added to the resulting jar for our extension's distribution.
|
|
|
+ */
|
|
|
+ implementation 'org.apache.commons:commons-lang3:3.11'
|
|
|
+
|
|
|
+ //All dependencies below are only for tests
|
|
|
+ testImplementation("org.testcontainers:testcontainers:1.15.2")
|
|
|
+ testImplementation("com.fasterxml.jackson.core:jackson-databind:2.11.2")
|
|
|
+ testImplementation("com.google.protobuf:protobuf-java-util:3.12.4")
|
|
|
+ testImplementation("com.squareup.okhttp3:okhttp:3.12.12")
|
|
|
+ testImplementation("io.opentelemetry:opentelemetry-api:${versions.opentelemetry}")
|
|
|
+ testImplementation("io.opentelemetry:opentelemetry-proto:${versions.opentelemetryAlpha}")
|
|
|
+
|
|
|
+ testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
|
|
|
+ testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
|
|
|
+ testRuntimeOnly("ch.qos.logback:logback-classic:1.2.3")
|
|
|
+
|
|
|
+ //Otel Java instrumentation that we use and extend during integration tests
|
|
|
+ otel("io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}:all")
|
|
|
+}
|
|
|
+
|
|
|
+tasks {
|
|
|
+ test {
|
|
|
+ useJUnitPlatform()
|
|
|
+
|
|
|
+ def extensionJar = tasks.shadowJar
|
|
|
+ inputs.files(layout.files(extensionJar))
|
|
|
+
|
|
|
+ doFirst {
|
|
|
+ //To run our tests with the javaagent published by OpenTelemetry Java instrumentation project
|
|
|
+ jvmArgs("-Dio.opentelemetry.smoketest.agentPath=${configurations.getByName("otel").resolve().find().absolutePath}")
|
|
|
+ //Instructs our integration test where to find our extension archive
|
|
|
+ jvmArgs("-Dio.opentelemetry.smoketest.extensionPath=${extensionJar.archiveFile.get()}")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ compileJava {
|
|
|
+ options.release.set(11)
|
|
|
+ }
|
|
|
+
|
|
|
+ assemble.dependsOn(shadowJar)
|
|
|
}
|