Enable Servlet request and response dispatcher instrumentation by default.
Change config for Servlet Filter and Service and JDBC DataSource instrumentation so it must be explicitly enabled (won't be enabled by accident if all of servlet is enabled).
MODIFY
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/DataSourceDecorator.java
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/DataSourceDecorator.java
@@ -7,7 +7,7 @@ public class DataSourceDecorator extends BaseDecorator {
@Override
protected String[] instrumentationNames() {
- return new String[] {"jdbc-beta", "jdbc-datasource"};
+ return new String[] {"jdbc-datasource"};
}
@Override

MODIFY
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/DataSourceInstrumentation.java
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/DataSourceInstrumentation.java
@@ -25,7 +25,7 @@ import net.bytebuddy.matcher.ElementMatcher;
@AutoService(Instrumenter.class)
public final class DataSourceInstrumentation extends Instrumenter.Default {
public DataSourceInstrumentation() {
- super("jdbc-beta", "jdbc-datasource");
+ super("jdbc-datasource");
}
@Override

MODIFY
dd-java-agent/instrumentation/jdbc/src/test/groovy/JDBCInstrumentationTest.groovy
dd-java-agent/instrumentation/jdbc/src/test/groovy/JDBCInstrumentationTest.groovy
@@ -5,7 +5,6 @@ import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.Config
import datadog.trace.api.DDSpanTypes
import datadog.trace.instrumentation.api.Tags
-import javax.sql.DataSource
import org.apache.derby.jdbc.EmbeddedDataSource
import org.apache.derby.jdbc.EmbeddedDriver
import org.h2.Driver
@@ -29,7 +28,7 @@ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
class JDBCInstrumentationTest extends AgentTestRunner {
static {
- System.setProperty("dd.integration.jdbc-beta.enabled", "true")
+ System.setProperty("dd.integration.jdbc-datasource.enabled", "true")
}
@Shared

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherDecorator.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherDecorator.java
@@ -7,7 +7,7 @@ public class RequestDispatcherDecorator extends BaseDecorator {
@Override
protected String[] instrumentationNames() {
- return new String[] {"servlet-beta", "servlet-dispatcher"};
+ return new String[] {"servlet", "servlet-dispatcher"};
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java
package datadog.trace.instrumentation.servlet.dispatcher;
+import static datadog.trace.agent.decorator.HttpServerDecorator.DD_SPAN_ATTRIBUTE;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.instrumentation.api.AgentTracer.activeSpan;
@@ -31,12 +32,7 @@ import net.bytebuddy.matcher.ElementMatcher;
@AutoService(Instrumenter.class)
public final class RequestDispatcherInstrumentation extends Instrumenter.Default {
public RequestDispatcherInstrumentation() {
- super("servlet-beta", "servlet-dispatcher");
- }
-
- @Override
- public boolean defaultEnabled() {
- return false;
+ super("servlet", "servlet-dispatcher");
}
@Override
@@ -91,15 +87,24 @@ public final class RequestDispatcherInstrumentation extends Instrumenter.Default
// In case we lose context, inject trace into to the request.
propagate().inject(span, request, SETTER);
+ // temporarily remove from request to avoid spring resource name bubbling up:
+ request.removeAttribute(DD_SPAN_ATTRIBUTE);
+
return activateSpan(span, true).setAsyncPropagation(true);
}
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stop(
- @Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) {
+ @Advice.Enter final AgentScope scope,
+ @Advice.Argument(0) final ServletRequest request,
+ @Advice.Thrown final Throwable throwable) {
if (scope == null) {
return;
}
+
+ // now add it back...
+ request.setAttribute(DD_SPAN_ATTRIBUTE, scope.span());
+
DECORATE.onError(scope, throwable);
DECORATE.beforeFinish(scope);
scope.close();

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/filter/FilterDecorator.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/filter/FilterDecorator.java
@@ -7,7 +7,7 @@ public class FilterDecorator extends BaseDecorator {
@Override
protected String[] instrumentationNames() {
- return new String[] {"servlet-beta", "servlet-filter"};
+ return new String[] {"servlet-filter"};
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/filter/FilterInstrumentation.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/filter/FilterInstrumentation.java
@@ -27,7 +27,7 @@ import net.bytebuddy.matcher.ElementMatcher;
@AutoService(Instrumenter.class)
public final class FilterInstrumentation extends Instrumenter.Default {
public FilterInstrumentation() {
- super("servlet-beta", "servlet-filter");
+ super("servlet-filter");
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletDecorator.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletDecorator.java
@@ -7,7 +7,7 @@ public class HttpServletDecorator extends BaseDecorator {
@Override
protected String[] instrumentationNames() {
- return new String[] {"servlet-beta", "servlet-service"};
+ return new String[] {"servlet-service"};
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletInstrumentation.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletInstrumentation.java
@@ -32,7 +32,7 @@ import net.bytebuddy.matcher.ElementMatcher;
@AutoService(Instrumenter.class)
public final class HttpServletInstrumentation extends Instrumenter.Default {
public HttpServletInstrumentation() {
- super("servlet-beta", "servlet-service");
+ super("servlet-service");
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletResponseDecorator.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletResponseDecorator.java
@@ -7,7 +7,7 @@ public class HttpServletResponseDecorator extends BaseDecorator {
@Override
protected String[] instrumentationNames() {
- return new String[] {"servlet-beta", "servlet-response"};
+ return new String[] {"servlet", "servlet-response"};
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletResponseInstrumentation.java
dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/http/HttpServletResponseInstrumentation.java
@@ -29,12 +29,7 @@ import net.bytebuddy.matcher.ElementMatcher;
@AutoService(Instrumenter.class)
public final class HttpServletResponseInstrumentation extends Instrumenter.Default {
public HttpServletResponseInstrumentation() {
- super("servlet-beta", "servlet-response");
- }
-
- @Override
- public boolean defaultEnabled() {
- return false;
+ super("servlet", "servlet-response");
}
@Override

MODIFY
dd-java-agent/instrumentation/servlet/src/test/groovy/FilterTest.groovy
dd-java-agent/instrumentation/servlet/src/test/groovy/FilterTest.groovy
import datadog.trace.agent.test.AgentTestRunner
+
import javax.servlet.Filter
import javax.servlet.FilterChain
import javax.servlet.FilterConfig
@@ -11,7 +12,7 @@ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
class FilterTest extends AgentTestRunner {
static {
- System.setProperty("dd.integration.servlet-beta.enabled", "true")
+ System.setProperty("dd.integration.servlet-filter.enabled", "true")
}
def "test doFilter no-parent"() {

MODIFY
dd-java-agent/instrumentation/servlet/src/test/groovy/HttpServletResponseTest.groovy
dd-java-agent/instrumentation/servlet/src/test/groovy/HttpServletResponseTest.groovy
import datadog.trace.agent.test.AgentTestRunner
import groovy.servlet.AbstractHttpServlet
+import spock.lang.Subject
+
import javax.servlet.ServletOutputStream
import javax.servlet.http.Cookie
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
-import spock.lang.Subject
import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
class HttpServletResponseTest extends AgentTestRunner {
- static {
- System.setProperty("dd.integration.servlet-beta.enabled", "true")
- }
@Subject
def response = new TestResponse()

MODIFY
dd-java-agent/instrumentation/servlet/src/test/groovy/HttpServletTest.groovy
dd-java-agent/instrumentation/servlet/src/test/groovy/HttpServletTest.groovy
import datadog.trace.agent.test.AgentTestRunner
import groovy.servlet.AbstractHttpServlet
+
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
@@ -8,7 +9,7 @@ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
class HttpServletTest extends AgentTestRunner {
static {
- System.setProperty("dd.integration.servlet-beta.enabled", "true")
+ System.setProperty("dd.integration.servlet-service.enabled", "true")
}
def req = Mock(HttpServletRequest) {

MODIFY
dd-java-agent/instrumentation/servlet/src/test/groovy/RequestDispatcherTest.groovy
dd-java-agent/instrumentation/servlet/src/test/groovy/RequestDispatcherTest.groovy
import datadog.trace.agent.test.AgentTestRunner
+
import javax.servlet.ServletException
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
@@ -7,9 +8,6 @@ import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
class RequestDispatcherTest extends AgentTestRunner {
- static {
- System.setProperty("dd.integration.servlet-beta.enabled", "true")
- }
def dispatcher = new RequestDispatcherUtils(Mock(HttpServletRequest), Mock(HttpServletResponse))

Enable Servlet request and response dispatcher instrumentation by default.

Change config for Servlet Filter and Service and JDBC DataSource instrumentation so it must be explicitly enabled (won't be enabled by accident if all of servlet is enabled).