Depend on netty 3.9 instrumentation
MODIFY
dd-java-agent/instrumentation/play-2.3/play-2.3.gradle
dd-java-agent/instrumentation/play-2.3/play-2.3.gradle
@@ -37,11 +37,13 @@ testSets {
dependencies {
main_java8Compile group: 'com.typesafe.play', name: 'play_2.11', version: '2.3.0'
+ testCompile project(':dd-java-agent:instrumentation:netty-3.9')
+
testCompile group: 'com.typesafe.play', name: 'play-java_2.11', version: '2.3.0'
testCompile group: 'com.typesafe.play', name: 'play-java-ws_2.11', version: '2.3.0'
- testCompile(group: 'com.typesafe.play', name: 'play-test_2.11', version: '2.3.0')
+ testCompile group: 'com.typesafe.play', name: 'play-test_2.11', version: '2.3.0'
latestDepTestCompile group: 'com.typesafe.play', name: 'play-java_2.11', version: '2.3.+'
latestDepTestCompile group: 'com.typesafe.play', name: 'play-java-ws_2.11', version: '2.3.+'
- latestDepTestCompile(group: 'com.typesafe.play', name: 'play-test_2.11', version: '2.3.+')
+ latestDepTestCompile group: 'com.typesafe.play', name: 'play-test_2.11', version: '2.3.+'
}

MODIFY
dd-java-agent/instrumentation/play-2.3/src/test/groovy/server/PlayServerTest.groovy
dd-java-agent/instrumentation/play-2.3/src/test/groovy/server/PlayServerTest.groovy
@@ -6,6 +6,7 @@ import datadog.trace.agent.test.base.HttpServerTest
import datadog.trace.api.DDSpanTypes
import datadog.trace.api.DDTags
import datadog.trace.bootstrap.instrumentation.api.Tags
+import datadog.trace.instrumentation.netty39.server.NettyHttpServerDecorator
import datadog.trace.instrumentation.play23.PlayHttpServerDecorator
import play.api.test.TestServer
@@ -26,12 +27,12 @@ class PlayServerTest extends HttpServerTest<TestServer> {
@Override
String component() {
- return "netty"
+ return NettyHttpServerDecorator.DECORATE.component()
}
@Override
String expectedOperationName() {
- return "play.server"
+ return "netty.request"
}
// We don't have instrumentation for this version of netty yet

MODIFY
dd-java-agent/instrumentation/play-2.3/src/test/scala/server/AsyncServer.scala
dd-java-agent/instrumentation/play-2.3/src/test/scala/server/AsyncServer.scala
package server
+import datadog.trace.agent.test.base.HttpServerTest
import datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint._
-import play.api.libs.concurrent.Execution.{defaultContext => ec}
import play.api.mvc.{Action, Handler, Results}
import play.api.test.{FakeApplication, TestServer}
@@ -9,16 +9,14 @@ import scala.concurrent.Future
object AsyncServer {
val routes: PartialFunction[(String, String), Handler] = {
- case ("GET", "/success") => Action.async { request => Future.successful(Results.Status(SUCCESS.getStatus).apply(SUCCESS.getBody)) }
- case ("GET", "/redirect") => Action.async { request => Future.successful(Results.Redirect(REDIRECT.getBody, REDIRECT.getStatus)) }
- case ("GET", "/query") => Action.async { result => Future.successful(Results.Status(QUERY_PARAM.getStatus).apply(QUERY_PARAM.getBody)) }
- case ("GET", "/error-status") => Action.async { result => Future {
- throw new RuntimeException(ERROR.getBody)
- }(ec)
- }
- case ("GET", "/exception") => Action.async { result => Future {
- throw new RuntimeException(ERROR.getBody)
- }(ec)
+ case ("GET", "/success") => Action.async { request => HttpServerTest.controller(SUCCESS, new AsyncControllerClosureAdapter(Future.successful(Results.Status(SUCCESS.getStatus).apply(SUCCESS.getBody)))) }
+ case ("GET", "/redirect") => Action.async { request => HttpServerTest.controller(REDIRECT, new AsyncControllerClosureAdapter(Future.successful(Results.Redirect(REDIRECT.getBody, REDIRECT.getStatus)))) }
+ case ("GET", "/query") => Action.async { result => HttpServerTest.controller(QUERY_PARAM, new AsyncControllerClosureAdapter(Future.successful(Results.Status(QUERY_PARAM.getStatus).apply(QUERY_PARAM.getBody)))) }
+ case ("GET", "/error-status") => Action.async { result => HttpServerTest.controller(ERROR, new AsyncControllerClosureAdapter(Future.successful(Results.Status(ERROR.getStatus).apply(ERROR.getBody)))) }
+ case ("GET", "/exception") => Action.async { result =>
+ HttpServerTest.controller(EXCEPTION, new AsyncBlockClosureAdapter(() => {
+ throw new Exception(EXCEPTION.getBody)
+ }))
}
}

MODIFY
dd-java-agent/instrumentation/play-2.3/src/test/scala/server/ControllerClosureAdapter.scala
dd-java-agent/instrumentation/play-2.3/src/test/scala/server/ControllerClosureAdapter.scala
@@ -16,3 +16,7 @@ class BlockClosureAdapter(block: () => Result) extends Closure[Result] {
class AsyncControllerClosureAdapter(response: Future[Result]) extends Closure[Future[Result]] {
override def call(): Future[Result] = response
}
+
+class AsyncBlockClosureAdapter(block: () => Future[Result]) extends Closure[Future[Result]] {
+ override def call(): Future[Result] = block()
+}

MODIFY
dd-java-agent/instrumentation/play-2.3/src/test/scala/server/SyncServer.scala
dd-java-agent/instrumentation/play-2.3/src/test/scala/server/SyncServer.scala
@@ -17,13 +17,11 @@ object SyncServer {
HttpServerTest.controller(QUERY_PARAM, new ControllerClosureAdapter(Results.Status(QUERY_PARAM.getStatus).apply(QUERY_PARAM.getBody)))
}
case ("GET", "/error-status") => Action { request =>
- HttpServerTest.controller(ERROR, new BlockClosureAdapter(() => {
- throw new RuntimeException(ERROR.getBody)
- }))
+ HttpServerTest.controller(QUERY_PARAM, new ControllerClosureAdapter(Results.Status(ERROR.getStatus).apply(ERROR.getBody)))
}
case ("GET", "/exception") => Action { request =>
HttpServerTest.controller(EXCEPTION, new BlockClosureAdapter(() => {
- throw new RuntimeException(EXCEPTION.getBody)
+ throw new Exception(EXCEPTION.getBody)
}))
}
}

MODIFY
dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy
dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy
@@ -24,7 +24,12 @@ import spock.lang.Unroll
import java.util.concurrent.atomic.AtomicBoolean
import static datadog.trace.agent.test.asserts.TraceAssert.assertTrace
-import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.*
+import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.ERROR
+import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
+import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
+import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
+import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.REDIRECT
+import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SUCCESS
import static datadog.trace.agent.test.utils.ConfigUtils.withConfigOverride
import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
@@ -528,7 +533,7 @@ abstract class HttpServerTest<SERVER> extends AgentTestRunner {
tags {
"$Tags.COMPONENT" component
"$Tags.SPAN_KIND" Tags.SPAN_KIND_SERVER
- "$Tags.PEER_PORT" { it == null || it instanceof Integer } // Optional
+ "$Tags.PEER_PORT" Integer
"$Tags.PEER_HOST_IPV4" { it == null || it == "127.0.0.1" } // Optional
"$Tags.HTTP_URL" "${endpoint.resolve(address)}"
"$Tags.HTTP_METHOD" method

MODIFY
dd-trace-ot/src/main/java/datadog/trace/common/writer/ListWriter.java
dd-trace-ot/src/main/java/datadog/trace/common/writer/ListWriter.java
@@ -39,13 +39,6 @@ public class ListWriter extends CopyOnWriteArrayList<List<DDSpan>> implements Wr
latches.add(latch);
}
if (!latch.await(20, TimeUnit.SECONDS)) {
- System.out.println(this);
- for (final List<DDSpan> trace : this) {
- System.out.println(trace.toString());
- for (final DDSpan span : trace) {
- System.out.println(span.toString());
- }
- }
throw new TimeoutException(
"Timeout waiting for " + number + " trace(s). ListWriter.size() == " + size());
}

Depend on netty 3.9 instrumentation