Enable concurrency tests for Play server
MODIFY
instrumentation/play/play-2.4/javaagent/src/test/groovy/server/PlayAsyncServerTest.groovy
instrumentation/play/play-2.4/javaagent/src/test/groovy/server/PlayAsyncServerTest.groovy
@@ -7,10 +7,13 @@ package server
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
+import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
+import static play.mvc.Http.Context.Implicit.request
+import io.opentelemetry.api.trace.Span
import java.util.concurrent.CompletableFuture
import java.util.function.Supplier
import play.libs.concurrent.HttpExecution
@@ -29,6 +32,14 @@ class PlayAsyncServerTest extends PlayServerTest {
Results.status(SUCCESS.getStatus(), SUCCESS.getBody())
}
}, HttpExecution.defaultContext())
+ } as Supplier)
+ .GET(INDEXED_CHILD.getPath()).routeTo({
+ CompletableFuture.supplyAsync({
+ controller(INDEXED_CHILD) {
+ Span.current().setAttribute("test.request.id", request().getQueryString("id") as long)
+ Results.status(INDEXED_CHILD.getStatus())
+ }
+ }, HttpExecution.defaultContext())
} as Supplier)
.GET(QUERY_PARAM.getPath()).routeAsync({
CompletableFuture.supplyAsync({

MODIFY
instrumentation/play/play-2.4/javaagent/src/test/groovy/server/PlayServerTest.groovy
instrumentation/play/play-2.4/javaagent/src/test/groovy/server/PlayServerTest.groovy
@@ -8,10 +8,13 @@ package server
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
+import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
+import static play.mvc.Http.Context.Implicit.request
+import io.opentelemetry.api.trace.Span
import io.opentelemetry.api.trace.StatusCode
import io.opentelemetry.instrumentation.test.AgentTestTrait
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
@@ -31,6 +34,12 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
controller(SUCCESS) {
Results.status(SUCCESS.getStatus(), SUCCESS.getBody())
}
+ } as Supplier)
+ .GET(INDEXED_CHILD.getPath()).routeTo({
+ controller(INDEXED_CHILD) {
+ Span.current().setAttribute("test.request.id", request().getQueryString("id") as long)
+ Results.status(INDEXED_CHILD.getStatus())
+ }
} as Supplier)
.GET(QUERY_PARAM.getPath()).routeTo({
controller(QUERY_PARAM) {
@@ -66,6 +75,11 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
true
}
+ @Override
+ boolean testConcurrency() {
+ return true
+ }
+
@Override
void handlerSpan(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint = SUCCESS) {
trace.span(index) {

Enable concurrency tests for Play server (#2911)