Add test.  Address other PR concerns
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
@@ -80,7 +80,8 @@ public class AgentInstaller {
"datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper")
.or(
named(
- "datadog.trace.bootstrap.instrumentation.java.concurrent.CallableWrapper")))))
+ "datadog.trace.bootstrap.instrumentation.java.concurrent.CallableWrapper")
+ .or(nameStartsWith("datadog.trace.agent.test"))))))
.or(nameStartsWith("datadog.opentracing."))
.or(nameStartsWith("datadog.slf4j."))
.or(nameStartsWith("net.bytebuddy."))
@@ -142,7 +143,7 @@ public class AgentInstaller {
try {
agentBuilder = instrumenter.instrument(agentBuilder);
numInstrumenters++;
- } catch (final Throwable e) {
+ } catch (final Exception | LinkageError e) {
log.error("Unable to load instrumentation {}", instrumenter.getClass().getName(), e);
}
}

ADD
dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/AgentInstallerTest.groovy
+package datadog.trace.agent.tooling
+
+import datadog.trace.agent.test.AgentTestRunner
+import datadog.trace.agent.test.TestClass
+
+class AgentInstallerTest extends AgentTestRunner {
+
+ def "Exception in instrumentation is limited to that instrumentation"() {
+ given:
+ TestClass instance = new TestClass()
+
+ when:
+ String returnValue = instance.doSomething()
+
+ then:
+ returnValue == "overridden value"
+ }
+}

ADD
dd-java-agent/agent-tooling/src/test/java/datadog/trace/agent/test/BadInstrumentation.java
+package datadog.trace.agent.test;
+
+import com.google.auto.service.AutoService;
+import datadog.trace.agent.tooling.Instrumenter;
+import java.util.Collections;
+import java.util.Map;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+@AutoService(Instrumenter.class)
+public class BadInstrumentation extends Instrumenter.Default {
+ public BadInstrumentation() {
+ super("bad-test-instrumentation");
+ }
+
+ @Override
+ public ElementMatcher<? super TypeDescription> typeMatcher() {
+ throw new RuntimeException("Test Exception");
+ }
+
+ @Override
+ public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
+ return Collections.emptyMap();
+ }
+}

ADD
dd-java-agent/agent-tooling/src/test/java/datadog/trace/agent/test/GoodInstrumentation.java
+package datadog.trace.agent.test;
+
+import static java.util.Collections.singletonMap;
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+import com.google.auto.service.AutoService;
+import datadog.trace.agent.tooling.Instrumenter;
+import java.util.Map;
+import net.bytebuddy.asm.Advice;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+@AutoService(Instrumenter.class)
+public class GoodInstrumentation extends Instrumenter.Default {
+
+ public GoodInstrumentation() {
+ super("good-test-instrumentation");
+ }
+
+ @Override
+ public ElementMatcher<? super TypeDescription> typeMatcher() {
+ return named(TestClass.class.getName());
+ }
+
+ @Override
+ public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
+ return singletonMap(named("doSomething"), GoodInstrumentationAdvice.class.getName());
+ }
+
+ public static class GoodInstrumentationAdvice {
+ @Advice.OnMethodExit
+ public static void changeReturn(@Advice.Return(readOnly = false) String originalValue) {
+ originalValue = "overridden value";
+ }
+ }
+}

ADD
dd-java-agent/agent-tooling/src/test/java/datadog/trace/agent/test/TestClass.java
+package datadog.trace.agent.test;
+
+public class TestClass {
+ public String doSomething() {
+ return "original value";
+ }
+}

Add test.  Address other PR concerns