Skip to content

Commit f47be74

Browse files
romtsnclaude
andcommitted
fix(otel): add default mergeServiceFiles for bootstrap service relocation
Shadow 9.x only applies package relocations to service files that are claimed by a ServiceFileTransformer. The ContextStorageProvider service file at META-INF/services/ was not being relocated because it wasn't handled by any transformer — only the inst/META-INF/services/ files were. Adding a default mergeServiceFiles() call ensures bootstrap service files (like ContextStorageProvider) go through the transformer and get properly relocated to their shaded paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5a29bc6 commit f47be74

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,15 @@ tasks {
156156
// would prevent service file merging.
157157
duplicatesStrategy = DuplicatesStrategy.INCLUDE
158158

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.
159+
// Shadow 9.x only applies relocations to service files handled by a ServiceFileTransformer.
160+
// We need two mergeServiceFiles calls:
161+
// 1. Default path (META-INF/services) — ensures bootstrap service files get relocated
162+
// (e.g., ContextStorageProvider → shaded path). Without this, Shadow 9.x skips
163+
// relocation for service file names/contents not claimed by a transformer.
164+
// 2. inst/ path — merges isolated agent service files from both the upstream agent
165+
// and the distro libs. Uses `path` instead of `include` filter because Shadow 9.x's
166+
// include() strips the `inst/` prefix on output.
167+
mergeServiceFiles()
163168
mergeServiceFiles { path = "inst/META-INF/services" }
164169
exclude("**/module-info.class")
165170
relocatePackages(this)

0 commit comments

Comments
 (0)