diff --git a/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/matcher/AdditionalLibraryIgnoresMatcher.java b/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/matcher/AdditionalLibraryIgnoresMatcher.java index 687b3b3c7f4..8d28bb3926f 100644 --- a/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/matcher/AdditionalLibraryIgnoresMatcher.java +++ b/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/matcher/AdditionalLibraryIgnoresMatcher.java @@ -43,7 +43,7 @@ public boolean matches(final T target) { if (name.startsWith("org.springframework.")) { if ((name.startsWith("org.springframework.aop.") - && !(name.equals("org.springframework.aop.interceptor.AsyncExecutionInterceptor"))) + && !name.equals("org.springframework.aop.interceptor.AsyncExecutionInterceptor")) || name.startsWith("org.springframework.cache.") || name.startsWith("org.springframework.dao.") || name.startsWith("org.springframework.ejb.") diff --git a/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpannedMethodInvocation.java b/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpannedMethodInvocation.java index 18af5a10410..efad69115d8 100644 --- a/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpannedMethodInvocation.java +++ b/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpannedMethodInvocation.java @@ -40,10 +40,10 @@ public Object proceed() throws Throwable { // if the delegate does async work is everything OK because of this? // if the delegate does async work, should I need to worry about it here? scope.setAsyncPropagation(true); - Object result = delegate.proceed(); - // question? Why can't this just be AutoCloseable? Dogma? + return delegate.proceed(); + } finally { + // question: Why can't this just be AutoCloseable? Dogma? span.finish(); - return result; } } diff --git a/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringAsyncAdvice.java b/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringAsyncAdvice.java index cdee3cb0f11..3454133fc87 100644 --- a/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringAsyncAdvice.java +++ b/dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringAsyncAdvice.java @@ -10,7 +10,6 @@ public class SpringAsyncAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static void scheduleAsync( @Advice.Argument(value = 0, readOnly = false) MethodInvocation invocation) { - // wrap so that when the invocation is invoked, it can be wrapped with a span's start and stop invocation = new SpannedMethodInvocation(activeSpan(), invocation); } } diff --git a/dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/groovy/SpringAsyncTest.groovy b/dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/groovy/SpringAsyncTest.groovy index 2ec9bcb0e1f..8f5f0f05c8e 100644 --- a/dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/groovy/SpringAsyncTest.groovy +++ b/dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/groovy/SpringAsyncTest.groovy @@ -1,5 +1,4 @@ import datadog.trace.agent.test.AgentTestRunner -import datadog.trace.api.Trace import org.springframework.context.annotation.AnnotationConfigApplicationContext import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace @@ -19,7 +18,6 @@ class SpringAsyncTest extends AgentTestRunner { trace(0, 3) { span(0) { resourceName "root" - threadNameStartsWith "main" } span(1) { resourceName "AsyncTask.async" @@ -34,42 +32,4 @@ class SpringAsyncTest extends AgentTestRunner { } } } - - def "context propagated to @async task" () { - setup: - def context = new AnnotationConfigApplicationContext(AsyncTaskConfig) - AsyncTask asyncTask = context.getBean(AsyncTask) - when: - runUnderTrace("root") { - asyncTask.async().join() - } - then: - assertTraces(1) { - trace(0, 2) { - span(0) { - resourceName "root" - threadNameStartsWith "main" - } - span(1) { - resourceName "AsyncTask.async" - threadNameStartsWith "SimpleAsyncTaskExecutor" - childOf span(0) - } - } - } - } - - static class Leaf { - - private int i - - Leaf(int i) { - this.i = i - } - - @Trace - int leaf() { - return i - } - } } diff --git a/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/AsyncTask.java b/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/AsyncTask.java index 27c05ec327d..01157ccf6b7 100644 --- a/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/AsyncTask.java +++ b/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/AsyncTask.java @@ -1,9 +1,8 @@ package datadog.smoketest.springboot; import datadog.smoketest.springboot.grpc.AsynchronousGreeter; -import org.springframework.scheduling.annotation.Async; - import java.util.concurrent.CompletableFuture; +import org.springframework.scheduling.annotation.Async; public class AsyncTask { diff --git a/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/SpringbootGrpcApplication.java b/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/SpringbootGrpcApplication.java index b86268e37f6..52defc38210 100644 --- a/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/SpringbootGrpcApplication.java +++ b/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/SpringbootGrpcApplication.java @@ -1,11 +1,10 @@ package datadog.smoketest.springboot; -import java.io.IOException; -import java.lang.management.ManagementFactory; - import datadog.smoketest.springboot.grpc.AsynchronousGreeter; import datadog.smoketest.springboot.grpc.LocalInterface; import datadog.smoketest.springboot.grpc.SynchronousGreeter; +import java.io.IOException; +import java.lang.management.ManagementFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; diff --git a/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/controller/WebController.java b/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/controller/WebController.java index 74bade965ab..7dc8eb7f29d 100644 --- a/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/controller/WebController.java +++ b/dd-smoke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/controller/WebController.java @@ -3,7 +3,6 @@ import datadog.smoketest.springboot.AsyncTask; import datadog.smoketest.springboot.grpc.AsynchronousGreeter; import datadog.smoketest.springboot.grpc.SynchronousGreeter; - import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; @@ -24,13 +23,13 @@ public class WebController { private final SynchronousGreeter greeter; private final AsyncTask asyncTask; - public WebController(AsynchronousGreeter asyncGreeter, SynchronousGreeter greeter, AsyncTask asyncTask) { + public WebController( + AsynchronousGreeter asyncGreeter, SynchronousGreeter greeter, AsyncTask asyncTask) { this.asyncGreeter = asyncGreeter; this.greeter = greeter; this.asyncTask = asyncTask; } - @RequestMapping("/greeting") public String greeting() { return greeter.greet(); @@ -79,5 +78,4 @@ public String call() { public String asyncAnnotationGreeting() { return asyncTask.greet().join(); } - }