Skip to content

Commit f696e30

Browse files
committed
revert asserting muzzle failures in instrumentation tests
1 parent fafc220 commit f696e30

3 files changed

Lines changed: 1 addition & 50 deletions

File tree

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/muzzle/MuzzleCheck.java

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
import datadog.trace.agent.tooling.InstrumenterModule;
44
import datadog.trace.agent.tooling.InstrumenterState;
55
import datadog.trace.agent.tooling.Utils;
6-
import java.util.Collections;
76
import java.util.List;
8-
import java.util.concurrent.CopyOnWriteArrayList;
97
import net.bytebuddy.matcher.ElementMatcher;
108
import org.slf4j.Logger;
119
import org.slf4j.LoggerFactory;
1210

1311
public class MuzzleCheck implements ElementMatcher<ClassLoader> {
1412
private static final Logger log = LoggerFactory.getLogger(MuzzleCheck.class);
1513

16-
private static final List<String> ERRORS = new CopyOnWriteArrayList<>();
17-
private static volatile boolean recordErrors = false;
18-
1914
private final int instrumentationId;
2015
private final String instrumentationClass;
2116
private final ReferenceProvider runtimeMuzzleReferences;
@@ -38,13 +33,9 @@ public boolean matches(ClassLoader classLoader) {
3833
InstrumenterState.applyInstrumentation(classLoader, instrumentationId);
3934
} else {
4035
InstrumenterState.blockInstrumentation(classLoader, instrumentationId);
41-
if (recordErrors || log.isDebugEnabled()) {
36+
if (log.isDebugEnabled()) {
4237
final List<Reference.Mismatch> mismatches =
4338
muzzle.getMismatchedReferenceSources(classLoader);
44-
if (recordErrors) {
45-
recordMuzzleMismatch(
46-
InstrumenterState.describe(instrumentationId), classLoader, mismatches);
47-
}
4839
log.debug(
4940
"Muzzled - {} instrumentation.target.classloader={}",
5041
InstrumenterState.describe(instrumentationId),
@@ -70,38 +61,4 @@ private ReferenceMatcher muzzle() {
7061
}
7162
return muzzle;
7263
}
73-
74-
/**
75-
* Record a muzzle mismatch error for test visibility.
76-
*
77-
* @param instrumentationDescription the description of the instrumentation that was blocked
78-
* @param classLoader the classloader where the instrumentation was blocked
79-
* @param mismatches the list of mismatch details
80-
*/
81-
private static void recordMuzzleMismatch(
82-
String instrumentationDescription,
83-
ClassLoader classLoader,
84-
List<Reference.Mismatch> mismatches) {
85-
StringBuilder sb = new StringBuilder();
86-
sb.append("Muzzled - ")
87-
.append(instrumentationDescription)
88-
.append(" instrumentation.target.classloader=")
89-
.append(classLoader)
90-
.append("\n");
91-
for (Reference.Mismatch mismatch : mismatches) {
92-
sb.append(" Mismatch: ").append(mismatch).append("\n");
93-
}
94-
ERRORS.add(sb.toString());
95-
}
96-
97-
// Visible for testing
98-
public static void enableRecordingAndReset() {
99-
recordErrors = true;
100-
ERRORS.clear();
101-
}
102-
103-
// Visible for testing
104-
public static List<String> getErrors() {
105-
return Collections.unmodifiableList(ERRORS);
106-
}
10764
}

dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/InstrumentationSpecification.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import datadog.trace.agent.tooling.InstrumenterModule
3939
import datadog.trace.agent.tooling.TracerInstaller
4040
import datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers
4141
import datadog.trace.agent.tooling.bytebuddy.matcher.GlobalIgnores
42-
import datadog.trace.agent.tooling.muzzle.MuzzleCheck
4342
import datadog.trace.api.Config
4443
import datadog.trace.api.IdGenerationStrategy
4544
import datadog.trace.api.Pair
@@ -479,7 +478,6 @@ abstract class InstrumentationSpecification extends DDSpecification implements A
479478
ActiveSubsystems.APPSEC_ACTIVE = true
480479
}
481480
InstrumentationErrors.enableRecordingAndReset()
482-
MuzzleCheck.enableRecordingAndReset()
483481
ProcessTags.reset()
484482
}
485483

@@ -523,8 +521,6 @@ abstract class InstrumentationSpecification extends DDSpecification implements A
523521
}
524522
def instrumentationErrorCount = InstrumentationErrors.getErrors().size()
525523
assert instrumentationErrorCount == 0, "${instrumentationErrorCount} instrumentation errors were seen:\n${InstrumentationErrors.getErrors().join("\n---\n")}"
526-
def muzzleErrorCount = MuzzleCheck.getErrors().size()
527-
assert muzzleErrorCount == 0, "${muzzleErrorCount} muzzle errors were seen:\n${MuzzleCheck.getErrors().join("\n---\n")}"
528524
}
529525

530526
private void doCheckRepeatedFinish() {

dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/asserts/ListWriterAssert.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package datadog.trace.agent.test.asserts
22

33
import static TraceAssert.assertTrace
44

5-
import datadog.trace.agent.tooling.muzzle.MuzzleCheck
65
import datadog.trace.bootstrap.InstrumentationErrors
76
import datadog.trace.common.writer.ListWriter
87
import datadog.trace.core.DDSpan
@@ -103,7 +102,6 @@ class ListWriterAssert {
103102

104103
static void assertNoErrors() {
105104
assert InstrumentationErrors.getErrors().size() == 0 : "Instrumentation errors were seen, failing fast"
106-
assert MuzzleCheck.getErrors().size() == 0 : "Muzzle errors were seen, failing fast"
107105
// InstrumentationSpecification.{cleanup,cleanupAfterAgent} will provide details later
108106
}
109107

0 commit comments

Comments
 (0)