Skip to content

Apply main forbidden APIs to instrumentation modules#11623

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
bdu/apply-main-forbidden-apis-to-instrumentation
Jun 12, 2026
Merged

Apply main forbidden APIs to instrumentation modules#11623
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
bdu/apply-main-forbidden-apis-to-instrumentation

Conversation

@bric3

@bric3 bric3 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Restores the intended forbidden-apis signature set for instrumentation modules: main.txt plus instrumentation.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 @SuppressForbidden because this is the existing one-character split fast-path pattern used elsewhere in the repo.
  • String#getBytes() in Spring Core muzzle code, changed to getBytes(UTF_8).
  • direct Byte Buddy ElementMatchers usage in Code Origin support, I kept as-is with because the existing matcher expression intentionally differs from the available HierarchyMatchers.

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:

  1. the forbidden-api task setup configures main.txt,
  2. then dd-java-agent/instrumentation/build.gradle mutates each CheckForbiddenApis task with signaturesFiles += 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:forbiddenApisMain only read instrumentation.txt.

This means that APIs covered only by main.txt were not checked in instrumentation modules.

This PR makes the task-level configuration explicit by assigning both files together.

Additional Details

  • By using --info to the forbiddenApisMain task, once can see what signature file are used.

  • The CodeOriginInstrumentation change is now using tracer's HierarchyMatchers. 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

    - isDeclaredBy(hasSuperType(isInterface().and(declaresMethod(isAnnotatedWith(matcher)))))
    + isDeclaredBy(implementsInterface(declaresMethod(isAnnotatedWith(matcher))))

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /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)
    • Get more information in this doc

Jira ticket: [N/A]

@bric3 bric3 requested a review from jpbempel June 10, 2026 18:14
@bric3 bric3 added comp: tooling Build & Tooling type: bug Bug report and fix tag: no release notes Changes to exclude from release notes labels Jun 10, 2026 — with ChatGPT Codex Connector
@datadog-datadog-prod-us1-2

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.97 s 13.91 s [-0.2%; +1.2%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 12.97 s [-1.2%; +0.6%] (no difference)
startup:petclinic:appsec:Agent 16.86 s 16.65 s [+0.4%; +2.2%] (maybe worse)
startup:petclinic:iast:Agent 16.86 s 16.91 s [-1.1%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.76 s 16.86 s [-1.7%; +0.5%] (no difference)
startup:petclinic:sca:Agent 16.86 s 16.76 s [-0.1%; +1.4%] (no difference)
startup:petclinic:tracing:Agent 15.99 s 16.01 s [-1.3%; +1.1%] (no difference)

Commit: a6e41883 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@bric3 bric3 requested a review from PerfectSlayer June 11, 2026 09:21
@bric3 bric3 marked this pull request as ready for review June 11, 2026 09:22
@bric3 bric3 requested review from a team as code owners June 11, 2026 09:22
@bric3 bric3 requested review from ValentinZakharov and andreimatei and removed request for a team June 11, 2026 09:22

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the main.txt is still applying to the instrumentations.

👏 praise:
Thanks for finding the issue and fixing the instrumentations!

@bric3 bric3 requested review from jpbempel and mcculls June 12, 2026 09:38
transformer.applyAdvice(
ElementMatchers.isDeclaredBy(
hasSuperType(isInterface().and(declaresMethod(isAnnotatedWith(matcher))))),
isDeclaredBy(implementsInterface(declaresMethod(isAnnotatedWith(matcher)))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks, isDeclaredBy(implementsInterface(...)) is the same as isDeclaredBy(hasSuperType(isInterface().and(...))) but more performant

@PerfectSlayer PerfectSlayer Jun 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back to commet on it following Yesterday’s discussion with @bric3 Glad you caught it @mcculls
Again, I have a tendency to overlook the PR when you push for review in person 😓

@bric3 bric3 Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mcculls mcculls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@bric3 bric3 added this pull request to the merge queue Jun 12, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 12, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-12 12:19:29 UTC ℹ️ Start processing command /merge


2026-06-12 12:19:40 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-06-12 13:24:42 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 12, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 2f0f3d8 into master Jun 12, 2026
577 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the bdu/apply-main-forbidden-apis-to-instrumentation branch June 12, 2026 13:24
@github-actions github-actions Bot added this to the 1.64.0 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling tag: no release notes Changes to exclude from release notes type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants