Move caffeine patching to instrumentation-api-caching (#3559)

This commit is contained in:
Mateusz Rzeszutek 2021-07-14 13:59:50 +02:00 committed by GitHub
parent 8318d5acc9
commit c1b5c0884d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 26 deletions

View File

@ -20,6 +20,11 @@ dependencies {
shadowInclude("com.blogspot.mydailyjava:weak-lock-free")
}
// patch inner class from Caffeine to avoid ForkJoinTask from being loaded too early in the javaagent
val patch by sourceSets.creating {
java {}
}
tasks {
shadowJar {
configurations = listOf(shadowInclude)
@ -32,7 +37,15 @@ tasks {
val extractShadowJar by registering(Copy::class) {
dependsOn(shadowJar)
from(zipTree(shadowJar.get().archiveFile))
// replace caffeine class with our patched version
from(zipTree(shadowJar.get().archiveFile)) {
exclude("io/opentelemetry/instrumentation/api/internal/shaded/caffeine/cache/BoundedLocalCache\$PerformCleanupTask.class")
}
from(patch.output) {
include("io/opentelemetry/instrumentation/api/internal/shaded/caffeine/cache/BoundedLocalCache\$PerformCleanupTask.class")
}
into("build/extracted/shadow")
// prevents empty com/github/benmanes/caffeine/cache path from ending up in instrumentation-api
includeEmptyDirs = false

View File

@ -33,6 +33,7 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")
testCompileOnly(project(":instrumentation-api-caching"))
testImplementation(project(":testing-common"))
testImplementation("org.mockito:mockito-core")
testImplementation("org.mockito:mockito-junit-jupiter")

View File

@ -1,12 +0,0 @@
plugins {
id("otel.java-conventions")
}
dependencies {
// For testing javaagent-bootstrap's Caffeine patch, we need to compile against our cache API
// but make sure to run against javaagent-bootstrap
testCompileOnly(project(":instrumentation-api-caching"))
testRuntimeOnly(project(":javaagent-bootstrap"))
testImplementation("org.assertj:assertj-core")
}

View File

@ -5,18 +5,6 @@ plugins {
group = "io.opentelemetry.javaagent"
// patch inner class from Caffeine to avoid ForkJoinTask from being loaded too early
val patch = sourceSets.create("patch")
patch.java {}
tasks {
named<Jar>("jar") {
from(patch.output) {
include("io/opentelemetry/instrumentation/api/internal/shaded/caffeine/cache/BoundedLocalCache\$PerformCleanupTask.class")
}
}
}
dependencies {
api("io.opentelemetry:opentelemetry-api")
api("io.opentelemetry:opentelemetry-api-metrics")

View File

@ -53,7 +53,6 @@ rootProject.name = "opentelemetry-java-instrumentation"
include(":opentelemetry-api-shaded-for-instrumenting")
include(":opentelemetry-ext-annotations-shaded-for-instrumenting")
include(":javaagent-bootstrap")
include(":javaagent-bootstrap-tests")
include(":javaagent-exporters")
include(":javaagent-extension-api")
include(":javaagent-tooling")