Prevent bootstrap classes from being included into agent classloader
MODIFY
instrumentation/instrumentation.gradle
instrumentation/instrumentation.gradle
@@ -34,16 +34,13 @@ subprojects {
}
dependencies {
- implementation project(':instrumentation-api')
- implementation project(':javaagent-api')
- implementation(project(':javaagent-tooling')) {
- exclude module: ':javaagent-bootstrap'
- }
+ compileOnly project(':instrumentation-api')
+ compileOnly project(':javaagent-api')
+ implementation(project(':javaagent-tooling'))
}
configurations {
// exclude bootstrap dependencies from shadowJar
- implementation.exclude module: deps.slf4j
implementation.exclude group: 'org.slf4j'
implementation.exclude group: 'io.opentelemetry', module: 'opentelemetry-api'
}
@@ -60,20 +57,18 @@ shadowJar {
duplicatesStrategy = DuplicatesStrategy.FAIL
dependencies {
+ //These classes are added to bootstrap classloader by javaagent module
exclude(project(':javaagent-bootstrap'))
+ exclude(project(':instrumentation-api'))
+ exclude(project(':javaagent-api'))
}
// rewrite library instrumentation dependencies
- relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation") {
- exclude "io.opentelemetry.javaagent.instrumentation.**"
- }
+ relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation")
// rewrite dependencies calling Logger.getLogger
relocate 'java.util.logging.Logger', 'io.opentelemetry.javaagent.bootstrap.PatchLogger'
- // prevents conflict with library instrumentation
- relocate 'io.opentelemetry.instrumentation.api', 'io.opentelemetry.javaagent.shaded.instrumentation.api'
-
// relocate OpenTelemetry API usage
relocate "io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api"
relocate "io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context"

MODIFY
javaagent-exporters/jaeger/jaeger.gradle
javaagent-exporters/jaeger/jaeger.gradle
@@ -16,6 +16,7 @@ dependencies {
implementation(deps.opentelemetryJaeger) {
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk'
+ exclude group: 'io.opentelemetry', module: 'opentelemetry-api'
}
implementation group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.30.2'
}

MODIFY
javaagent-exporters/otlp/otlp.gradle
javaagent-exporters/otlp/otlp.gradle
@@ -16,6 +16,7 @@ dependencies {
implementation(deps.opentelemetryOtlp) {
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk'
+ exclude group: 'io.opentelemetry', module: 'opentelemetry-api'
}
implementation group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.30.2'
}

Prevent bootstrap classes from being included into agent classloader (#1646)