Apply default decorators in unit tests
MODIFY
dd-java-agent/testing/src/main/java/datadog/trace/agent/test/AgentTestRunner.java
dd-java-agent/testing/src/main/java/datadog/trace/agent/test/AgentTestRunner.java
package datadog.trace.agent.test;
import datadog.opentracing.DDTracer;
+import datadog.opentracing.decorators.AbstractDecorator;
+import datadog.opentracing.decorators.DBTypeDecorator;
+import datadog.opentracing.decorators.DDDecoratorsFactory;
import datadog.trace.agent.tooling.AgentInstaller;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.common.writer.ListWriter;
+
import io.opentracing.Tracer;
+
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
+import java.util.List;
+
import net.bytebuddy.agent.ByteBuddyAgent;
+
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.spockframework.runtime.model.SpecMetadata;
+
import spock.lang.Specification;
/**
@@ -45,6 +54,11 @@ public abstract class AgentTestRunner extends Specification {
static {
TEST_WRITER = new ListWriter();
TEST_TRACER = new DDTracer(TEST_WRITER);
+
+ final List<AbstractDecorator> decorators = DDDecoratorsFactory.createFromResources();
+ for (final AbstractDecorator decorator : decorators) {
+ ((DDTracer) TEST_TRACER).addDecorator(decorator);
+ }
ByteBuddyAgent.install();
instrumentation = ByteBuddyAgent.getInstrumentation();
}

ADD
dd-java-agent/testing/src/main/resources/dd-trace-decorators.yaml
+# Decorators are used to add extra information to span
+# Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator
+decorators:
+ - type: HTTPComponent
+ matchingValue: java-okhttp
+ setValue: http-client
+ - type: HTTPComponent
+ matchingValue: java-aws-sdk
+ setValue: aws-client
+ - type: ErrorFlag
+ - type: DBTypeDecorator
+ - type: DBStatementAsResourceName
+ - type: OperationDecorator
+ - type: Status404Decorator
+ - type: URLAsResourceName

Apply default decorators in unit tests