Apply main forbidden APIs to instrumentation modules#11623
Conversation
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. |
PerfectSlayer
left a comment
There was a problem hiding this comment.
Checked the main.txt is still applying to the instrumentations.
👏 praise:
Thanks for finding the issue and fixing the instrumentations!
| transformer.applyAdvice( | ||
| ElementMatchers.isDeclaredBy( | ||
| hasSuperType(isInterface().and(declaresMethod(isAnnotatedWith(matcher))))), | ||
| isDeclaredBy(implementsInterface(declaresMethod(isAnnotatedWith(matcher)))), |
There was a problem hiding this comment.
👍 thanks, isDeclaredBy(implementsInterface(...)) is the same as isDeclaredBy(hasSuperType(isInterface().and(...))) but more performant
There was a problem hiding this comment.
No problem, also sorry @PerfectSlayer, I had some questions and our offline discussions confirmed there was something to look again. There was a reason it was a reason why it was made like that (see #11017), but this allowed to improve the situation.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What Does This Do
Restores the intended forbidden-apis signature set for instrumentation modules:
main.txtplusinstrumentation.txt.The stricter check surfaced a few existing calls that were previously leaking through:
String#split(String)in Liberty filename parsing, kept with a narrow@SuppressForbiddenbecause this is the existing one-character split fast-path pattern used elsewhere in the repo.String#getBytes()in Spring Core muzzle code, changed togetBytes(UTF_8).ElementMatchersusage in Code Origin support, I kept as-is with because the existing matcher expression intentionally differs from the availableHierarchyMatchers.Motivation
Follow-up to #11620.Actually it can be merged before.Instrumentation forbidden-apis tasks were not properly configured to use
main.txt.This was already true on
master, and it surfaced while working on #11620:main.txt,dd-java-agent/instrumentation/build.gradlemutates eachCheckForbiddenApistask withsignaturesFiles += instrumentation.txt,...but it's not working as expected.
With the forbidden-apis Gradle plugin task property/convention wiring, that task-level
+=did not merge with the extension's "default" in the way it was supposedly (as far as I understand) intended. In practice, that means that forbidden api instrumentation tasks such as:dd-java-agent:instrumentation:liberty:liberty-20.0:forbiddenApisMainonly readinstrumentation.txt.This means that APIs covered only by
main.txtwere not checked in instrumentation modules.This PR makes the task-level configuration explicit by assigning both files together.
Additional Details
By using
--infoto theforbiddenApisMaintask, once can see what signature file are used.The
CodeOriginInstrumentationchange is now using tracer'sHierarchyMatchers. In particular the change should keep the Fix CodeOrigin for interface endpoints #11017.The API is a bit different on the surface, but should behave the same way
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue/merge. You can also:/merge --commit-message "..."/merge -c/merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)Jira ticket: [N/A]