Repository navigation
Rerun build-time instrumentation when a classpath class body changes - #13384
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
Conversation
Build-time instrumentation runs as a post-compile step and reads classpath classes beyond their signatures: muzzle records which library methods a helper calls. The compile task's classpath input only fingerprints the ABI (compile avoidance), so a change to a helper's method body in another source set or project left the compile, and its generated $Muzzle side class, cached and stale. Register the classpath as an instrumentation input with full classpath normalization, so any class change reruns it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
The extra classpath input covers body-only dependency changes that ABI-based compile avoidance misses, preventing reuse of stale $Muzzle output.
🤖 Bits Code Review · Commit 5a3c62c
This comment has been minimized.
This comment has been minimized.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
AlexeyKuznetsov-DD
left a comment
There was a problem hiding this comment.
Awesome catch, left minor comment about test.
The test's ByteBuddy plugin now calls lib.Helper.value() through the instrumenting class loader and records the result as a field, so each build asserts instrumentation saw that build's helper body, not just that the compile reran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/merge |
|
View all feedbacks in Devflow UI.
It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.
devflow unqueued this merge request: It did not become mergeable within the expected time |
chore: Completed code comments., and tweaked the code a tiny bit Use kotlin extension function, and a constant for the inout name. Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com>
What Does This Do
Makes build-time instrumentation rerun when any class on the compile classpath changes, not just when its signatures change. A body-only change to a helper in another source set or project could reuse a cached compile, whose generated
$Muzzleside class still described the old code.Motivation
validate_build: [false]rebuilds the agent and compares it with thebuildjob's jars. It fails on #13357, #13358 and #13359, while master passes. On #13358 the jardiff shows one file differing between two builds of the same commit:inst/datadog/trace/instrumentation/micronaut/v4_0/MicronautInstrumentation$Muzzle.classdata.The build-time instrumentation runs as a
doLaston each main compile task. It scans the tracer's advice and helpers to find the classes, methods and fields they require from the application's libraries, and records those requirements in$Muzzle. At runtime, Muzzle checks those requirements against the application's class loader to determine library compatibility.Although
AbstractCompile.getClasspath()is annotated with@Classpath,JavaCompile.getClasspath()overrides it with@CompileClasspath. The latter fingerprints the classpath's application binary interface (ABI) for compile avoidance and ignores method-body changes. A helper's implementation can change its library requirements while its own ABI stays the same.#13358 changed a method body in
MicronautDecorator, in the module'smain_java17source set, which is oncompileJava's classpath. The ABI didn't change, so thebuildjob reused a cachedcompileJavawhose$Muzzlewas computed against the old decorator, and a cacheless rebuild produced a different one.Beyond CI, a cached build could ship muzzle references that don't match the helper code.
Additional Notes
classpathas an extra input namedinstrumentationCompileClasspath, using the privateINSTRUMENTATION_COMPILE_CLASSPATHconstant. ItsClasspathNormalizertracks full class contents, including method bodies, while ignoring absolute paths, JAR entry order and timestamps, so cache entries still relocate.buildTimeInstrumentationPlugininput uses the same normalizer to track the ByteBuddy plugins and their dependencies, whose implementation also affects the instrumented output. The new input tracks the classes those plugins resolve and inspect.instrumentationCompileClasspathtracksclasspathonly. The worker's assembledinstrumentingClassPathalso containsadditionalClasspathandtmpUninstrumentedClasses.otel-bootstrap) now rerun on any classpath class change, including body-only ones, instead of hitting the cache. That's the price of the instrumentation reading those bodies.BuildTimeInstrumentationPluginTestgains a TestKit case that changes only a method body in a dependency project and asserts:compileJavareruns. Without the fix it fails withexpected: SUCCESS but was: UP_TO_DATE; with the fix all 4 tests in the class pass. The rest of the buildSrc suite passes too (the JVM-path assertions inTestJvmConstraintsPluginTestdepend on which JDK 17 isJAVA_HOME; with Zulu 17 they pass).micronaut-http-server-netty-4.0, changing only a method body inMicronautDecorator(main_java17) now rerunscompileJava.call-site-instrumentation-plugin/.../PluginApplication.javaon master fails:call-site-instrumentation-plugin:spotlessJavaCheck. It's unrelated and left out here.Gradle best-practices audit (scoped to
buildSrc/.../plugin/instrument/and its consumers). These are existing findings, out of scope here, and worth follow-ups:dont_access_project_instance_inside_task(High):InstrumentPostProcessingActioninjectsProjectand callsproject.configurations.named(…)inside thedoLastaction, which blocks the configuration cache.avoid_eager_file_collection_apis(High):it.source.isEmptyin thematching { }predicate resolves each compile task's sources at configuration time.use_attributes_on_configurations(High): the resolvablebuildTimeInstrumentationPluginconfiguration has no attributes, and both consumers selectconfiguration = "buildTimeInstrumentationToolingPlugins"by name.default_path_sensitivities(Medium, heuristic): theadditionalClasspathandincludeClassDirectoriesinputs default to absolute path sensitivity.🤖 Generated with Claude Code