Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dd-java-agent/instrumentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ subprojects { Project subProj ->

// Add instrumentation-specific forbiddenApi rules
subProj.tasks.withType(CheckForbiddenApis).configureEach {
signaturesFiles += subProj.files("$rootDir/gradle/forbiddenApiFilters/instrumentation.txt")
signaturesFiles = subProj.files(
"$rootDir/gradle/forbiddenApiFilters/main.txt",
"$rootDir/gradle/forbiddenApiFilters/instrumentation.txt")
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package datadog.trace.instrumentation.codeorigin;

import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.declaresMethod;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;

import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule.Tracing;
import datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers;
import datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers;
import datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.OneOf;
import datadog.trace.api.InstrumenterConfig;
Expand All @@ -16,7 +15,6 @@
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;

public abstract class CodeOriginInstrumentation extends Tracing
implements Instrumenter.ForTypeHierarchy, Instrumenter.HasMethodAdvice {
Expand Down Expand Up @@ -44,26 +42,20 @@ public String hierarchyMarkerType() {
@Override
public ElementMatcher<TypeDescription> hierarchyMatcher() {
ElementMatcher.Junction<TypeDescription> matcher =
HierarchyMatchers.declaresMethod(HierarchyMatchers.isAnnotatedWith(this.matcher));
declaresMethod(isAnnotatedWith(this.matcher));
if (InstrumenterConfig.get().isCodeOriginInterfaceSupport()) {
matcher =
matcher.or(
HierarchyMatchers.implementsInterface(
HierarchyMatchers.declaresMethod(
HierarchyMatchers.isAnnotatedWith(this.matcher))));
matcher = matcher.or(implementsInterface(declaresMethod(isAnnotatedWith(this.matcher))));
}
return matcher;
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
HierarchyMatchers.isAnnotatedWith(matcher),
"datadog.trace.instrumentation.codeorigin.EntrySpanOriginAdvice");
isAnnotatedWith(matcher), "datadog.trace.instrumentation.codeorigin.EntrySpanOriginAdvice");
if (InstrumenterConfig.get().isCodeOriginInterfaceSupport()) {
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.

"datadog.trace.instrumentation.codeorigin.EntrySpanOriginAdvice");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.liberty20;

import de.thetaphi.forbiddenapis.SuppressForbidden;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -48,6 +49,7 @@ private static String getSubmittedFilename(Method method, Object part) {
}
}

@SuppressForbidden // split on single-character uses a fast path
private static String getFilenameFromContentDisposition(Method getHeader, Object part) {
if (getHeader == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog.trace.instrumentation.springcore;

import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static java.nio.charset.StandardCharsets.UTF_8;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
Expand Down Expand Up @@ -56,7 +57,7 @@ public static void checkReturnedObject(

private static void muzzleCheck() throws IOException {
StreamUtils.copyToString(
new ByteArrayInputStream("test".getBytes()), Charset.defaultCharset());
new ByteArrayInputStream("test".getBytes(UTF_8)), Charset.defaultCharset());
}
}
}