Skip to content

Commit affe804

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-instrumentation into indy-servlet3
2 parents da8d9bc + 78b3c6a commit affe804

File tree

10 files changed

+60
-22
lines changed

10 files changed

+60
-22
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ java -javaagent:path/to/opentelemetry-javaagent.jar \
8080
-jar myapp.jar
8181
```
8282

83-
By default, the OpenTelemetry Java agent uses
83+
By default, the OpenTelemetry Java agent uses the
8484
[OTLP exporter](https://github.com/open-telemetry/opentelemetry-java/tree/main/exporters/otlp)
85-
configured to send data to
85+
configured to send data to an
8686
[OpenTelemetry collector](https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/otlpreceiver/README.md)
8787
at `http://localhost:4318`.
8888

@@ -197,6 +197,6 @@ Thanks to all the people who already contributed!
197197

198198
[config-sdk]: https://opentelemetry.io/docs/languages/java/configuration/
199199

200-
[manual]: https://opentelemetry.io/docs/instrumentation/java/manual/
200+
[manual]: https://opentelemetry.io/docs/languages/java/instrumentation/#manual-instrumentation
201201

202-
[suppress]: https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/#suppressing-specific-auto-instrumentation
202+
[suppress]: https://opentelemetry.io/docs/zero-code/java/agent/disable/

conventions/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ dependencies {
6464
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.1")
6565
implementation("org.spdx:spdx-gradle-plugin:0.8.0")
6666
// When updating, also update dependencyManagement/build.gradle.kts
67-
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.15.9")
67+
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.15.10")
6868
implementation("gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.6")
6969
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2")
7070
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.1.0")

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ val DEPENDENCY_BOMS = listOf(
4141
val autoServiceVersion = "1.1.1"
4242
val autoValueVersion = "1.11.0"
4343
val errorProneVersion = "2.35.1"
44-
val byteBuddyVersion = "1.15.9"
44+
val byteBuddyVersion = "1.15.10"
4545
val asmVersion = "9.7.1"
4646
val jmhVersion = "1.37"
4747
val mockitoVersion = "4.11.0"

gradle-plugins/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ configurations.named("compileOnly") {
2424
extendsFrom(bbGradlePlugin)
2525
}
2626

27-
val byteBuddyVersion = "1.15.9"
27+
val byteBuddyVersion = "1.15.10"
2828
val aetherVersion = "1.1.0"
2929

3030
dependencies {

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ private static void installBytebuddyAgent(
137137
.with(new RedefinitionDiscoveryStrategy())
138138
.with(AgentBuilder.DescriptionStrategy.Default.POOL_ONLY)
139139
.with(AgentTooling.poolStrategy())
140-
.with(new ClassLoadListener())
141140
.with(AgentTooling.transformListener())
142141
.with(AgentTooling.locationStrategy());
143142
if (JavaModule.isSupported()) {
@@ -172,6 +171,7 @@ private static void installBytebuddyAgent(
172171
agentListener.beforeAgent(autoConfiguredSdk);
173172
}
174173

174+
agentBuilder = agentBuilder.with(new ClassLoadListener());
175175
agentBuilder = configureIgnoredTypes(sdkConfig, extensionClassLoader, agentBuilder);
176176

177177
int numberOfLoadedExtensions = 0;

javaagent/build.gradle.kts

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,43 @@ tasks {
141141
archiveFileName.set("bootstrapLibs.jar")
142142
}
143143

144-
val relocateBaseJavaagentLibs by registering(ShadowJar::class) {
144+
val relocateBaseJavaagentLibsTmp by registering(ShadowJar::class) {
145145
configurations = listOf(baseJavaagentLibs)
146146

147147
excludeBootstrapClasses()
148148

149149
duplicatesStrategy = DuplicatesStrategy.FAIL
150150

151+
archiveFileName.set("baseJavaagentLibs-relocated-tmp.jar")
152+
}
153+
154+
val relocateBaseJavaagentLibs by registering(Jar::class) {
155+
dependsOn(relocateBaseJavaagentLibsTmp)
156+
157+
copyByteBuddy(relocateBaseJavaagentLibsTmp.get().archiveFile)
158+
159+
duplicatesStrategy = DuplicatesStrategy.FAIL
160+
151161
archiveFileName.set("baseJavaagentLibs-relocated.jar")
152162
}
153163

154-
val relocateJavaagentLibs by registering(ShadowJar::class) {
164+
val relocateJavaagentLibsTmp by registering(ShadowJar::class) {
155165
configurations = listOf(javaagentLibs)
156166

157167
excludeBootstrapClasses()
158168

159169
duplicatesStrategy = DuplicatesStrategy.FAIL
160170

171+
archiveFileName.set("javaagentLibs-relocated-tmp.jar")
172+
}
173+
174+
val relocateJavaagentLibs by registering(Jar::class) {
175+
dependsOn(relocateJavaagentLibsTmp)
176+
177+
copyByteBuddy(relocateJavaagentLibsTmp.get().archiveFile)
178+
179+
duplicatesStrategy = DuplicatesStrategy.FAIL
180+
161181
archiveFileName.set("javaagentLibs-relocated.jar")
162182
}
163183

@@ -363,6 +383,24 @@ fun CopySpec.isolateClasses(jar: Provider<RegularFile>) {
363383
}
364384
}
365385

386+
fun CopySpec.copyByteBuddy(jar: Provider<RegularFile>) {
387+
// Byte buddy jar includes classes compiled for java 5 at the root of the jar and the same classes
388+
// compiled for java 8 under META-INF/versions/9. Here we move the classes from
389+
// META-INF/versions/9/net/bytebuddy to net/bytebuddy to get rid of the duplicate classes.
390+
from(zipTree(jar)) {
391+
eachFile {
392+
if (path.startsWith("net/bytebuddy/") &&
393+
// this is our class that we have placed in the byte buddy package, need to preserve it
394+
!path.startsWith("net/bytebuddy/agent/builder/AgentBuilderUtil")) {
395+
exclude()
396+
} else if (path.startsWith("META-INF/versions/9/net/bytebuddy/")) {
397+
path = path.removePrefix("META-INF/versions/9/")
398+
}
399+
}
400+
includeEmptyDirs = false
401+
}
402+
}
403+
366404
// exclude bootstrap projects from javaagent libs - they won't be added to inst/
367405
fun ShadowJar.excludeBootstrapClasses() {
368406
dependencies {

licenses/licenses.md

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smoke-tests/images/quarkus/build.gradle.kts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ dependencies {
2020
implementation("io.quarkus:quarkus-rest")
2121
}
2222

23-
quarkus {
24-
// Expected by jib extension.
25-
// TODO(anuraaga): Switch to quarkus plugin native jib support.
26-
setFinalName("opentelemetry-quarkus-$version")
27-
}
28-
2923
// Quarkus 3.7+ requires Java 17+
3024
val targetJDK = project.findProperty("targetJDK") ?: "17"
3125

@@ -34,10 +28,10 @@ val tag = findProperty("tag")
3428

3529
java {
3630
// this is needed to avoid jib failing with
37-
// "Your project is using Java 17 but the base image is for Java 8"
31+
// "Your project is using Java 21 but the base image is for Java 17"
3832
// (it seems the jib plugins does not understand toolchains yet)
39-
sourceCompatibility = JavaVersion.VERSION_1_8
40-
targetCompatibility = JavaVersion.VERSION_1_8
33+
sourceCompatibility = JavaVersion.VERSION_17
34+
targetCompatibility = JavaVersion.VERSION_17
4135
}
4236

4337
jib {
@@ -46,6 +40,12 @@ jib {
4640
container {
4741
mainClass = "bogus" // to suppress Jib warning about missing main class
4842
}
43+
pluginExtensions {
44+
pluginExtension {
45+
implementation = "com.google.cloud.tools.jib.gradle.extension.quarkus.JibQuarkusExtension"
46+
properties = mapOf("packageType" to "fast-jar")
47+
}
48+
}
4949
}
5050

5151
tasks {

0 commit comments

Comments
 (0)