Skip to content

Commit 23d0439

Browse files
author
Andrew Kent
committed
Remove muzzle dead code, doc cleanup, and better logging
1 parent 2925df8 commit 23d0439

File tree

4 files changed

+7
-67
lines changed

4 files changed

+7
-67
lines changed

buildSrc/src/main/groovy/MuzzlePlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.gradle.api.Project
44
import java.lang.reflect.Method
55

66
/**
7-
* POC muzzle task plugin which runs muzzle validation against an instrumentation's compile-time dependencies.
7+
* muzzle task plugin which runs muzzle validation against an instrumentation's compile-time dependencies.
88
*
99
* <p/>TODO: merge this with version scan
1010
*/

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Instrumenter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,16 @@ public boolean matches(
9090
JavaModule module,
9191
Class<?> classBeingRedefined,
9292
ProtectionDomain protectionDomain) {
93-
// Optimization: calling getMuzzleReferenceMatcher() inside this method prevents unnecessary loading of muzzle references during agentBuilder setup.
93+
// Optimization: calling getInstrumentationMuzzle() inside this method prevents unnecessary loading of muzzle references during agentBuilder setup.
9494
final ReferenceMatcher muzzle = getInstrumentationMuzzle();
9595
if (null != muzzle) {
9696
List<Reference.Mismatch> mismatches =
9797
muzzle.getMismatchedReferenceSources(classLoader);
9898
if (mismatches.size() > 0) {
9999
log.debug(
100-
"Instrumentation muzzled: {} on {}",
100+
"Instrumentation muzzled: {} -- {} on {}",
101101
instrumentationPrimaryName,
102+
this.getClass().getName(),
102103
classLoader);
103104
}
104105
for (Reference.Mismatch mismatch : mismatches) {
@@ -149,6 +150,8 @@ protected boolean defaultEnabled() {
149150
return getConfigEnabled("dd.integrations.enabled", true);
150151
}
151152

153+
// TODO: move common config helpers to Utils
154+
152155
public static String getPropOrEnv(final String name) {
153156
return System.getProperty(name, System.getenv(propToEnvName(name)));
154157
}
Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
package datadog.trace.agent.tooling.muzzle;
22

33
import datadog.trace.agent.tooling.Instrumenter;
4-
import net.bytebuddy.asm.AsmVisitorWrapper;
54
import net.bytebuddy.build.Plugin;
6-
import net.bytebuddy.description.field.FieldDescription;
7-
import net.bytebuddy.description.field.FieldList;
8-
import net.bytebuddy.description.method.MethodList;
95
import net.bytebuddy.description.type.TypeDefinition;
106
import net.bytebuddy.description.type.TypeDescription;
117
import net.bytebuddy.dynamic.DynamicType.Builder;
12-
import net.bytebuddy.implementation.Implementation;
13-
import net.bytebuddy.jar.asm.ClassVisitor;
14-
import net.bytebuddy.jar.asm.MethodVisitor;
15-
import net.bytebuddy.jar.asm.Opcodes;
16-
import net.bytebuddy.pool.TypePool;
178

189
/** Bytebuddy gradle plugin which creates muzzle-references at compile time. */
1910
public class MuzzleGradlePlugin implements Plugin {
@@ -52,58 +43,4 @@ public Builder<?> apply(Builder<?> builder, TypeDescription typeDescription) {
5243
return builder;
5344
}
5445
}
55-
56-
private static class RemoveFinalFlagVisitor implements AsmVisitorWrapper {
57-
final String methodName;
58-
59-
public RemoveFinalFlagVisitor(String methodName) {
60-
this.methodName = methodName;
61-
}
62-
63-
@Override
64-
public int mergeWriter(int flags) {
65-
return flags;
66-
}
67-
68-
@Override
69-
public int mergeReader(int flags) {
70-
return flags;
71-
}
72-
73-
@Override
74-
public ClassVisitor wrap(
75-
TypeDescription instrumentedType,
76-
ClassVisitor classVisitor,
77-
Implementation.Context implementationContext,
78-
TypePool typePool,
79-
FieldList<FieldDescription.InDefinedShape> fields,
80-
MethodList<?> methods,
81-
int writerFlags,
82-
int readerFlags) {
83-
return new Visitor(classVisitor);
84-
}
85-
86-
private class Visitor extends ClassVisitor {
87-
public Visitor(ClassVisitor cv) {
88-
super(Opcodes.ASM6, cv);
89-
}
90-
91-
@Override
92-
public MethodVisitor visitMethod(
93-
final int access,
94-
final String name,
95-
final String descriptor,
96-
final String signature,
97-
final String[] exceptions) {
98-
MethodVisitor methodVisitor =
99-
super.visitMethod(access, name, descriptor, signature, exceptions);
100-
if (name.equals(methodName) && (access & Opcodes.ACC_FINAL) != 0) {
101-
return super.visitMethod(
102-
access ^ Opcodes.ACC_FINAL, name, descriptor, signature, exceptions);
103-
} else {
104-
return super.visitMethod(access, name, descriptor, signature, exceptions);
105-
}
106-
}
107-
}
108-
}
10946
}

dd-java-agent/instrumentation/apache-httpclient-4.3/src/main/java/datadog/trace/instrumentation/apachehttpclient/ApacheHttpClientInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public ElementMatcher<? super ClassLoader> classLoaderMatcher() {
4545
public String[] helperClassNames() {
4646
return new String[] {
4747
"datadog.trace.instrumentation.apachehttpclient.DDTracingClientExec",
48-
"datadog.trace.instrumentation.apachehttpclient.DDTracingClientExec$HttpHeadersInjectAdapter",
48+
"datadog.trace.instrumentation.apachehttpclient.DDTracingClientExec$HttpHeadersInjectAdapter"
4949
};
5050
}
5151

0 commit comments

Comments
 (0)