Use builtin decorators for every DDTracer
MODIFY
dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServletTest.groovy
dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServletTest.groovy
@@ -99,7 +99,7 @@ class JettyServletTest extends AgentTestRunner {
span.context().serviceName == "unnamed-java-app"
span.context().operationName == "servlet.request"
- span.context().resourceName == "servlet.request"
+ span.context().resourceName == "GET /$path"
span.context().spanType == DDSpanTypes.WEB_SERVLET
!span.context().getErrorFlag()
span.context().parentId != 0 // parent should be the okhttp call.
@@ -134,7 +134,7 @@ class JettyServletTest extends AgentTestRunner {
def span = trace[0]
span.context().operationName == "servlet.request"
- span.context().resourceName == "servlet.request"
+ span.context().resourceName == "GET /$path"
span.context().spanType == DDSpanTypes.WEB_SERVLET
span.context().getErrorFlag()
span.context().parentId != 0 // parent should be the okhttp call.

MODIFY
dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServletTest.groovy
dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServletTest.groovy
import datadog.opentracing.DDSpan
import datadog.opentracing.DDTracer
-import datadog.opentracing.decorators.AbstractDecorator
-import datadog.opentracing.decorators.DDDecoratorsFactory
import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.DDSpanTypes
import datadog.trace.common.writer.ListWriter
@@ -54,10 +52,6 @@ class JettyServletTest extends AgentTestRunner {
DDTracer tracer = new DDTracer(writer)
def setup() {
- final List<AbstractDecorator> decorators = DDDecoratorsFactory.createBuiltinDecorators()
- for (final AbstractDecorator decorator : decorators) {
- tracer.addDecorator(decorator)
- }
jettyServer = new Server(PORT)
servletContext = new ServletContextHandler()

MODIFY
dd-java-agent/instrumentation/servlet-3/src/test/groovy/TomcatServletTest.groovy
dd-java-agent/instrumentation/servlet-3/src/test/groovy/TomcatServletTest.groovy
import com.google.common.io.Files
import datadog.opentracing.DDTracer
-import datadog.opentracing.decorators.AbstractDecorator
-import datadog.opentracing.decorators.DDDecoratorsFactory
import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.DDSpanTypes
import datadog.trace.common.writer.ListWriter
@@ -35,11 +33,6 @@ class TomcatServletTest extends AgentTestRunner {
DDTracer tracer = new DDTracer(writer)
def setup() {
- final List<AbstractDecorator> decorators = DDDecoratorsFactory.createBuiltinDecorators()
- for (final AbstractDecorator decorator : decorators) {
- tracer.addDecorator(decorator)
- }
-
tomcatServer = new Tomcat()
tomcatServer.setPort(PORT)

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
@@ -4,8 +4,6 @@ import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import datadog.opentracing.DDSpan;
import datadog.opentracing.DDTracer;
-import datadog.opentracing.decorators.AbstractDecorator;
-import datadog.opentracing.decorators.DDDecoratorsFactory;
import datadog.trace.agent.tooling.AgentInstaller;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.common.writer.ListWriter;
@@ -78,10 +76,6 @@ public abstract class AgentTestRunner extends Specification {
};
TEST_TRACER = new DDTracer(TEST_WRITER);
- final List<AbstractDecorator> decorators = DDDecoratorsFactory.createBuiltinDecorators();
- for (final AbstractDecorator decorator : decorators) {
- ((DDTracer) TEST_TRACER).addDecorator(decorator);
- }
ByteBuddyAgent.install();
instrumentation = ByteBuddyAgent.getInstrumentation();
}

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java
dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java
@@ -92,13 +92,6 @@ public class DDTracer implements io.opentracing.Tracer {
Sampler.Builder.forConfig(config),
DDTraceConfig.parseMap(config.getProperty(DDTraceConfig.SPAN_TAGS)));
log.debug("Using config: {}", config);
-
- // Create decorators from resource files
- final List<AbstractDecorator> decorators = DDDecoratorsFactory.createBuiltinDecorators();
- for (final AbstractDecorator decorator : decorators) {
- log.debug("Loading decorator: {}", decorator.getClass().getSimpleName());
- addDecorator(decorator);
- }
}
public DDTracer(final String serviceName, final Writer writer, final Sampler sampler) {
@@ -126,6 +119,12 @@ public class DDTracer implements io.opentracing.Tracer {
registerClassLoader(ClassLoader.getSystemClassLoader());
+ final List<AbstractDecorator> decorators = DDDecoratorsFactory.createBuiltinDecorators();
+ for (final AbstractDecorator decorator : decorators) {
+ log.debug("Loading decorator: {}", decorator.getClass().getSimpleName());
+ addDecorator(decorator);
+ }
+
log.info("New instance: {}", this);
}

Use builtin decorators for every DDTracer