Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstartin committed Sep 16, 2020
1 parent daebf6a commit 211a644
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,7 +18,6 @@ class SpringAsyncTest extends AgentTestRunner {
trace(0, 3) {
span(0) {
resourceName "root"
threadNameStartsWith "main"
}
span(1) {
resourceName "AsyncTask.async"
Expand All @@ -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
}
}
}
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -79,5 +78,4 @@ public String call() {
public String asyncAnnotationGreeting() {
return asyncTask.greet().join();
}

}

0 comments on commit 211a644

Please sign in to comment.