Skip to content

Commit 5a29bc6

Browse files
romtsnclaude
andcommitted
fix(otel): use mergeServiceFiles path instead of include for Shadow 9.x
Shadow 9.x's ServiceFileTransformer strips the `inst/` prefix when using `include("inst/META-INF/services/*")`, placing merged service files under `META-INF/services/` instead of `inst/META-INF/services/`. This breaks the OTel agent's classloader which expects isolated services under `inst/`. Using `path = "inst/META-INF/services"` preserves the correct output path. Also add missing `duplicatesStrategy = DuplicatesStrategy.INCLUDE` to console-otlp, log4j2, and console-opentelemetry-noagent shadow JARs so that mergeServiceFiles and Log4j2 transformers can see duplicates before they are deduplicated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5bfc096 commit 5a29bc6

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

sentry-opentelemetry/sentry-opentelemetry-agent/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ tasks {
156156
// would prevent service file merging.
157157
duplicatesStrategy = DuplicatesStrategy.INCLUDE
158158

159-
mergeServiceFiles { include("inst/META-INF/services/*") }
159+
// Use `path` instead of `include` filter so that the merged service files are
160+
// written back to `inst/META-INF/services/` (the agent classloader's isolated path).
161+
// Using `include("inst/META-INF/services/*")` with Shadow 9.x strips the `inst/`
162+
// prefix and writes to `META-INF/services/`, which breaks the agent's class loading.
163+
mergeServiceFiles { path = "inst/META-INF/services" }
160164
exclude("**/module-info.class")
161165
relocatePackages(this)
162166

sentry-samples/sentry-samples-console-opentelemetry-noagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dependencies {
4848
tasks.shadowJar {
4949
manifest { attributes["Main-Class"] = "io.sentry.samples.console.Main" }
5050
archiveClassifier.set("") // Remove the classifier so it replaces the regular JAR
51+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
5152
mergeServiceFiles()
5253
}
5354

sentry-samples/sentry-samples-console-otlp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ dependencies {
5151
tasks.shadowJar {
5252
manifest { attributes["Main-Class"] = "io.sentry.samples.console.Main" }
5353
archiveClassifier.set("") // Remove the classifier so it replaces the regular JAR
54+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
5455
mergeServiceFiles()
5556
}
5657

sentry-samples/sentry-samples-log4j2/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ dependencies {
4545
tasks.shadowJar {
4646
manifest { attributes["Main-Class"] = "io.sentry.samples.log4j2.Main" }
4747
archiveClassifier.set("") // Remove the classifier so it replaces the regular JAR
48+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
4849
mergeServiceFiles()
4950
// Use Log4j2 cache transformer to properly handle plugin files
5051
transform(

0 commit comments

Comments
 (0)