http servers

This commit is contained in:
Tyler Benson 2018-07-26 16:10:12 +10:00
parent 3856e7fd1a
commit 00a2e891b0
15 changed files with 63 additions and 45 deletions

View File

@ -89,7 +89,7 @@ class LagomTest extends AgentTestRunner {
"$Tags.HTTP_URL.key" "ws://localhost:${server.port()}/echo" "$Tags.HTTP_URL.key" "ws://localhost:${server.port()}/echo"
"$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_METHOD.key" "GET"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
"$Tags.COMPONENT.key" "akka-http-server" "$Tags.COMPONENT.key" "akka-http-server"
} }
} }
@ -127,7 +127,7 @@ class LagomTest extends AgentTestRunner {
"$Tags.HTTP_URL.key" "ws://localhost:${server.port()}/error" "$Tags.HTTP_URL.key" "ws://localhost:${server.port()}/error"
"$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_METHOD.key" "GET"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
"$Tags.COMPONENT.key" "akka-http-server" "$Tags.COMPONENT.key" "akka-http-server"
"$Tags.ERROR.key" true "$Tags.ERROR.key" true
} }

View File

@ -110,7 +110,7 @@ public final class AkkaHttpServerInstrumentation extends Instrumenter.Default {
.asChildOf(extractedContext) .asChildOf(extractedContext)
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.withTag(Tags.HTTP_METHOD.getKey(), request.method().value()) .withTag(Tags.HTTP_METHOD.getKey(), request.method().value())
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.WEB_SERVLET) .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_SERVER)
.withTag(Tags.COMPONENT.getKey(), "akka-http-server") .withTag(Tags.COMPONENT.getKey(), "akka-http-server")
.withTag(Tags.HTTP_URL.getKey(), request.getUri().toString()) .withTag(Tags.HTTP_URL.getKey(), request.getUri().toString())
.startActive(false); .startActive(false);

View File

@ -52,6 +52,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "GET /test" resourceName "GET /test"
spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
defaultTags() defaultTags()
@ -59,7 +60,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
"$Tags.HTTP_URL.key" "http://localhost:$port/test" "$Tags.HTTP_URL.key" "http://localhost:$port/test"
"$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_METHOD.key" "GET"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
"$Tags.COMPONENT.key" "akka-http-server" "$Tags.COMPONENT.key" "akka-http-server"
} }
} }
@ -94,6 +95,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "GET /$endpoint" resourceName "GET /$endpoint"
spanType DDSpanTypes.HTTP_SERVER
errored true errored true
tags { tags {
defaultTags() defaultTags()
@ -101,7 +103,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
"$Tags.HTTP_URL.key" "http://localhost:$port/$endpoint" "$Tags.HTTP_URL.key" "http://localhost:$port/$endpoint"
"$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_METHOD.key" "GET"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
"$Tags.COMPONENT.key" "akka-http-server" "$Tags.COMPONENT.key" "akka-http-server"
errorTags RuntimeException, errorMessage errorTags RuntimeException, errorMessage
} }
@ -134,6 +136,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "GET /server-error" resourceName "GET /server-error"
spanType DDSpanTypes.HTTP_SERVER
errored true errored true
tags { tags {
defaultTags() defaultTags()
@ -141,7 +144,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
"$Tags.HTTP_URL.key" "http://localhost:$port/server-error" "$Tags.HTTP_URL.key" "http://localhost:$port/server-error"
"$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_METHOD.key" "GET"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
"$Tags.COMPONENT.key" "akka-http-server" "$Tags.COMPONENT.key" "akka-http-server"
"$Tags.ERROR.key" true "$Tags.ERROR.key" true
} }
@ -173,6 +176,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "404" resourceName "404"
spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
defaultTags() defaultTags()
@ -180,7 +184,7 @@ class AkkaHttpServerInstrumentationTest extends AgentTestRunner {
"$Tags.HTTP_URL.key" "http://localhost:$port/not-found" "$Tags.HTTP_URL.key" "http://localhost:$port/not-found"
"$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_METHOD.key" "GET"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
"$Tags.COMPONENT.key" "akka-http-server" "$Tags.COMPONENT.key" "akka-http-server"
} }
} }

View File

@ -37,7 +37,7 @@ public class JettyHandlerAdvice {
.buildSpan("jetty.request") .buildSpan("jetty.request")
.asChildOf(extractedContext) .asChildOf(extractedContext)
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.WEB_SERVLET) .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_SERVER)
.withTag("servlet.context", req.getContextPath()) .withTag("servlet.context", req.getContextPath())
.withTag("span.origin.type", source.getClass().getName()) .withTag("span.origin.type", source.getClass().getName())
.startActive(false); .startActive(false);

View File

@ -64,14 +64,14 @@ class JettyHandlerTest extends AgentTestRunner {
context.serviceName == "unnamed-java-app" context.serviceName == "unnamed-java-app"
context.operationName == "jetty.request" context.operationName == "jetty.request"
context.resourceName == "GET ${handler.class.name}" context.resourceName == "GET ${handler.class.name}"
context.spanType == DDSpanTypes.WEB_SERVLET context.spanType == DDSpanTypes.HTTP_SERVER
!context.getErrorFlag() !context.getErrorFlag()
context.parentId == "0" context.parentId == "0"
def tags = context.tags def tags = context.tags
tags["http.url"] == "http://localhost:$port/" tags["http.url"] == "http://localhost:$port/"
tags["http.method"] == "GET" tags["http.method"] == "GET"
tags["span.kind"] == "server" tags["span.kind"] == "server"
tags["span.type"] == "web" tags["span.type"] == DDSpanTypes.HTTP_SERVER
tags["component"] == "jetty-handler" tags["component"] == "jetty-handler"
tags["http.status_code"] == 200 tags["http.status_code"] == 200
tags["thread.name"] != null tags["thread.name"] != null
@ -152,14 +152,14 @@ class JettyHandlerTest extends AgentTestRunner {
context.serviceName == "unnamed-java-app" context.serviceName == "unnamed-java-app"
context.operationName == "jetty.request" context.operationName == "jetty.request"
context.resourceName == "GET ${handler.class.name}" context.resourceName == "GET ${handler.class.name}"
context.spanType == DDSpanTypes.WEB_SERVLET context.spanType == DDSpanTypes.HTTP_SERVER
context.getErrorFlag() context.getErrorFlag()
context.parentId == "0" context.parentId == "0"
def tags = context.tags def tags = context.tags
tags["http.url"] == "http://localhost:$port/" tags["http.url"] == "http://localhost:$port/"
tags["http.method"] == "GET" tags["http.method"] == "GET"
tags["span.kind"] == "server" tags["span.kind"] == "server"
tags["span.type"] == "web" tags["span.type"] == DDSpanTypes.HTTP_SERVER
tags["component"] == "jetty-handler" tags["component"] == "jetty-handler"
tags["http.status_code"] == 500 tags["http.status_code"] == 500
tags["thread.name"] != null tags["thread.name"] != null

View File

@ -47,7 +47,7 @@ public class HttpServerRequestTracingHandler extends ChannelInboundHandlerAdapte
.withTag(Tags.HTTP_METHOD.getKey(), request.getMethod().name()) .withTag(Tags.HTTP_METHOD.getKey(), request.getMethod().name())
.withTag(Tags.HTTP_URL.getKey(), url) .withTag(Tags.HTTP_URL.getKey(), url)
.withTag(Tags.COMPONENT.getKey(), "netty") .withTag(Tags.COMPONENT.getKey(), "netty")
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.WEB_SERVLET) .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_SERVER)
.startActive(false); .startActive(false);
if (scope instanceof TraceScope) { if (scope instanceof TraceScope) {

View File

@ -57,7 +57,7 @@ class Netty40ServerTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "netty.request" operationName "netty.request"
resourceName "GET /" resourceName "GET /"
spanType DDSpanTypes.WEB_SERVLET spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
"$Tags.COMPONENT.key" "netty" "$Tags.COMPONENT.key" "netty"
@ -67,7 +67,7 @@ class Netty40ServerTest extends AgentTestRunner {
"$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOSTNAME.key" "localhost"
"$Tags.PEER_PORT.key" Integer "$Tags.PEER_PORT.key" Integer
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
defaultTags() defaultTags()
} }
} }
@ -103,7 +103,7 @@ class Netty40ServerTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "netty.request" operationName "netty.request"
resourceName name resourceName name
spanType DDSpanTypes.WEB_SERVLET spanType DDSpanTypes.HTTP_SERVER
errored error errored error
tags { tags {
"$Tags.COMPONENT.key" "netty" "$Tags.COMPONENT.key" "netty"
@ -113,7 +113,7 @@ class Netty40ServerTest extends AgentTestRunner {
"$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOSTNAME.key" "localhost"
"$Tags.PEER_PORT.key" Integer "$Tags.PEER_PORT.key" Integer
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
if (error) { if (error) {
tag("error", true) tag("error", true)
} }

View File

@ -47,7 +47,7 @@ public class HttpServerRequestTracingHandler extends ChannelInboundHandlerAdapte
.withTag(Tags.HTTP_METHOD.getKey(), request.method().name()) .withTag(Tags.HTTP_METHOD.getKey(), request.method().name())
.withTag(Tags.HTTP_URL.getKey(), url) .withTag(Tags.HTTP_URL.getKey(), url)
.withTag(Tags.COMPONENT.getKey(), "netty") .withTag(Tags.COMPONENT.getKey(), "netty")
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.WEB_SERVLET) .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_SERVER)
.startActive(false); .startActive(false);
if (scope instanceof TraceScope) { if (scope instanceof TraceScope) {

View File

@ -57,7 +57,7 @@ class Netty41ServerTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "netty.request" operationName "netty.request"
resourceName "GET /" resourceName "GET /"
spanType DDSpanTypes.WEB_SERVLET spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
"$Tags.COMPONENT.key" "netty" "$Tags.COMPONENT.key" "netty"
@ -67,7 +67,7 @@ class Netty41ServerTest extends AgentTestRunner {
"$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOSTNAME.key" "localhost"
"$Tags.PEER_PORT.key" Integer "$Tags.PEER_PORT.key" Integer
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
defaultTags() defaultTags()
} }
} }
@ -103,7 +103,7 @@ class Netty41ServerTest extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "netty.request" operationName "netty.request"
resourceName name resourceName name
spanType DDSpanTypes.WEB_SERVLET spanType DDSpanTypes.HTTP_SERVER
errored error errored error
tags { tags {
"$Tags.COMPONENT.key" "netty" "$Tags.COMPONENT.key" "netty"
@ -113,7 +113,7 @@ class Netty41ServerTest extends AgentTestRunner {
"$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOSTNAME.key" "localhost"
"$Tags.PEER_PORT.key" Integer "$Tags.PEER_PORT.key" Integer
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_SERVER
"$DDTags.SPAN_TYPE" DDSpanTypes.WEB_SERVLET "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_SERVER
if (error) { if (error) {
tag("error", true) tag("error", true)
} }

View File

@ -1,5 +1,6 @@
import datadog.trace.agent.test.AgentTestRunner import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.agent.test.TestUtils import datadog.trace.agent.test.TestUtils
import datadog.trace.api.DDSpanTypes
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import play.api.test.TestServer import play.api.test.TestServer
@ -50,6 +51,7 @@ class Play26Test extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "GET /helloplay/:from" resourceName "GET /helloplay/:from"
spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
defaultTags() defaultTags()
@ -57,7 +59,7 @@ class Play26Test extends AgentTestRunner {
"http.url" "http://localhost:$port/helloplay/spock" "http.url" "http://localhost:$port/helloplay/spock"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "akka-http-server" "component" "akka-http-server"
} }
} }
@ -65,13 +67,14 @@ class Play26Test extends AgentTestRunner {
childOf span(0) childOf span(0)
operationName "play.request" operationName "play.request"
resourceName "GET /helloplay/:from" resourceName "GET /helloplay/:from"
spanType DDSpanTypes.HTTP_SERVER
tags { tags {
defaultTags() defaultTags()
"http.status_code" 200 "http.status_code" 200
"http.url" "/helloplay/:from" "http.url" "/helloplay/:from"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "play-action" "component" "play-action"
} }
} }
@ -100,6 +103,7 @@ class Play26Test extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "GET /make-error" resourceName "GET /make-error"
spanType DDSpanTypes.HTTP_SERVER
errored true errored true
tags { tags {
defaultTags() defaultTags()
@ -107,7 +111,7 @@ class Play26Test extends AgentTestRunner {
"http.url" "http://localhost:$port/make-error" "http.url" "http://localhost:$port/make-error"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "akka-http-server" "component" "akka-http-server"
"error" true "error" true
} }
@ -116,6 +120,7 @@ class Play26Test extends AgentTestRunner {
childOf span(0) childOf span(0)
operationName "play.request" operationName "play.request"
resourceName "GET /make-error" resourceName "GET /make-error"
spanType DDSpanTypes.HTTP_SERVER
errored true errored true
tags { tags {
defaultTags() defaultTags()
@ -123,7 +128,7 @@ class Play26Test extends AgentTestRunner {
"http.url" "/make-error" "http.url" "/make-error"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "play-action" "component" "play-action"
"error" true "error" true
} }
@ -150,6 +155,7 @@ class Play26Test extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "GET /exception" resourceName "GET /exception"
spanType DDSpanTypes.HTTP_SERVER
errored true errored true
tags { tags {
defaultTags() defaultTags()
@ -157,7 +163,7 @@ class Play26Test extends AgentTestRunner {
"http.url" "http://localhost:$port/exception" "http.url" "http://localhost:$port/exception"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "akka-http-server" "component" "akka-http-server"
"error" true "error" true
} }
@ -166,6 +172,7 @@ class Play26Test extends AgentTestRunner {
childOf span(0) childOf span(0)
operationName "play.request" operationName "play.request"
resourceName "GET /exception" resourceName "GET /exception"
spanType DDSpanTypes.HTTP_SERVER
errored true errored true
tags { tags {
defaultTags() defaultTags()
@ -173,7 +180,7 @@ class Play26Test extends AgentTestRunner {
"http.url" "/exception" "http.url" "/exception"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "play-action" "component" "play-action"
"error" true "error" true
"error.msg" "oh no" "error.msg" "oh no"
@ -203,6 +210,7 @@ class Play26Test extends AgentTestRunner {
serviceName "unnamed-java-app" serviceName "unnamed-java-app"
operationName "akka-http.request" operationName "akka-http.request"
resourceName "404" resourceName "404"
spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
defaultTags() defaultTags()
@ -210,7 +218,7 @@ class Play26Test extends AgentTestRunner {
"http.url" "http://localhost:$port/nowhere" "http.url" "http://localhost:$port/nowhere"
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "akka-http-server" "component" "akka-http-server"
} }
} }
@ -218,13 +226,14 @@ class Play26Test extends AgentTestRunner {
childOf span(0) childOf span(0)
operationName "play.request" operationName "play.request"
resourceName "404" resourceName "404"
spanType DDSpanTypes.HTTP_SERVER
errored false errored false
tags { tags {
defaultTags() defaultTags()
"http.status_code" 404 "http.status_code" 404
"http.method" "GET" "http.method" "GET"
"span.kind" "server" "span.kind" "server"
"span.type" "web" "span.type" DDSpanTypes.HTTP_SERVER
"component" "play-action" "component" "play-action"
} }
} }

View File

@ -128,7 +128,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
scope.span().setTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER); scope.span().setTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER);
scope.span().setTag(Tags.HTTP_METHOD.getKey(), req.method()); scope.span().setTag(Tags.HTTP_METHOD.getKey(), req.method());
scope.span().setTag(DDTags.SPAN_TYPE, DDSpanTypes.WEB_SERVLET); scope.span().setTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_SERVER);
scope.span().setTag(Tags.COMPONENT.getKey(), "play-action"); scope.span().setTag(Tags.COMPONENT.getKey(), "play-action");
if (throwable == null) { if (throwable == null) {

View File

@ -1,6 +1,7 @@
import datadog.opentracing.DDSpan import datadog.opentracing.DDSpan
import datadog.trace.agent.test.AgentTestRunner import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.agent.test.TestUtils import datadog.trace.agent.test.TestUtils
import datadog.trace.api.DDSpanTypes
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import play.api.test.TestServer import play.api.test.TestServer
@ -51,6 +52,7 @@ class Play24Test extends AgentTestRunner {
root.serviceName == "unnamed-java-app" root.serviceName == "unnamed-java-app"
root.operationName == "play.request" root.operationName == "play.request"
root.resourceName == "GET /helloplay/:from" root.resourceName == "GET /helloplay/:from"
root.spanType == DDSpanTypes.HTTP_SERVER
!root.context().getErrorFlag() !root.context().getErrorFlag()
root.context().tags["http.status_code"] == 200 root.context().tags["http.status_code"] == 200
root.context().tags["http.url"] == "/helloplay/:from" root.context().tags["http.url"] == "/helloplay/:from"
@ -78,6 +80,7 @@ class Play24Test extends AgentTestRunner {
root.serviceName == "unnamed-java-app" root.serviceName == "unnamed-java-app"
root.operationName == "play.request" root.operationName == "play.request"
root.resourceName == "GET /make-error" root.resourceName == "GET /make-error"
root.spanType == DDSpanTypes.HTTP_SERVER
root.context().getErrorFlag() root.context().getErrorFlag()
root.context().tags["http.status_code"] == 500 root.context().tags["http.status_code"] == 500
root.context().tags["http.url"] == "/make-error" root.context().tags["http.url"] == "/make-error"
@ -109,6 +112,7 @@ class Play24Test extends AgentTestRunner {
root.serviceName == "unnamed-java-app" root.serviceName == "unnamed-java-app"
root.operationName == "play.request" root.operationName == "play.request"
root.resourceName == "GET /exception" root.resourceName == "GET /exception"
root.spanType == DDSpanTypes.HTTP_SERVER
root.context().tags["http.status_code"] == 500 root.context().tags["http.status_code"] == 500
root.context().tags["http.url"] == "/exception" root.context().tags["http.url"] == "/exception"
root.context().tags["http.method"] == "GET" root.context().tags["http.method"] == "GET"
@ -135,6 +139,7 @@ class Play24Test extends AgentTestRunner {
root.serviceName == "unnamed-java-app" root.serviceName == "unnamed-java-app"
root.operationName == "play.request" root.operationName == "play.request"
root.resourceName == "404" root.resourceName == "404"
root.spanType == DDSpanTypes.HTTP_SERVER
!root.context().getErrorFlag() !root.context().getErrorFlag()
root.context().tags["http.status_code"] == 404 root.context().tags["http.status_code"] == 404
root.context().tags["http.url"] == null root.context().tags["http.url"] == null

View File

@ -19,8 +19,8 @@ import ratpack.http.Status;
*/ */
public final class TracingHandler implements Handler { public final class TracingHandler implements Handler {
@Override @Override
public void handle(Context ctx) { public void handle(final Context ctx) {
Request request = ctx.getRequest(); final Request request = ctx.getRequest();
final SpanContext extractedContext = final SpanContext extractedContext =
GlobalTracer.get() GlobalTracer.get()
@ -32,7 +32,7 @@ public final class TracingHandler implements Handler {
.asChildOf(extractedContext) .asChildOf(extractedContext)
.withTag(Tags.COMPONENT.getKey(), "handler") .withTag(Tags.COMPONENT.getKey(), "handler")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.WEB_SERVLET) .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_SERVER)
.withTag(Tags.HTTP_METHOD.getKey(), request.getMethod().getName()) .withTag(Tags.HTTP_METHOD.getKey(), request.getMethod().getName())
.withTag(Tags.HTTP_URL.getKey(), request.getUri()) .withTag(Tags.HTTP_URL.getKey(), request.getUri())
.startActive(true); .startActive(true);
@ -40,9 +40,9 @@ public final class TracingHandler implements Handler {
ctx.getResponse() ctx.getResponse()
.beforeSend( .beforeSend(
response -> { response -> {
Span span = scope.span(); final Span span = scope.span();
span.setTag(DDTags.RESOURCE_NAME, getResourceName(ctx)); span.setTag(DDTags.RESOURCE_NAME, getResourceName(ctx));
Status status = response.getStatus(); final Status status = response.getStatus();
if (status != null) { if (status != null) {
if (status.is5xx()) { if (status.is5xx()) {
Tags.ERROR.set(span, true); Tags.ERROR.set(span, true);
@ -55,7 +55,7 @@ public final class TracingHandler implements Handler {
ctx.next(); ctx.next();
} }
private static String getResourceName(Context ctx) { private static String getResourceName(final Context ctx) {
String description = ctx.getPathBinding().getDescription(); String description = ctx.getPathBinding().getDescription();
if (description == null || description.isEmpty()) { if (description == null || description.isEmpty()) {
description = ctx.getRequest().getUri(); description = ctx.getRequest().getUri();

View File

@ -52,7 +52,7 @@ class RatpackTest extends AgentTestRunner {
span.context().operationName == "ratpack.handler" span.context().operationName == "ratpack.handler"
span.context().resourceName == "GET /" span.context().resourceName == "GET /"
span.context().tags["component"] == "handler" span.context().tags["component"] == "handler"
span.context().spanType == DDSpanTypes.WEB_SERVLET span.context().spanType == DDSpanTypes.HTTP_SERVER
!span.context().getErrorFlag() !span.context().getErrorFlag()
span.context().tags["http.url"] == "/" span.context().tags["http.url"] == "/"
span.context().tags["http.method"] == "GET" span.context().tags["http.method"] == "GET"
@ -92,7 +92,7 @@ class RatpackTest extends AgentTestRunner {
span.context().operationName == "ratpack.handler" span.context().operationName == "ratpack.handler"
span.context().resourceName == "GET /:foo/:bar?/baz" span.context().resourceName == "GET /:foo/:bar?/baz"
span.context().tags["component"] == "handler" span.context().tags["component"] == "handler"
span.context().spanType == DDSpanTypes.WEB_SERVLET span.context().spanType == DDSpanTypes.HTTP_SERVER
!span.context().getErrorFlag() !span.context().getErrorFlag()
span.context().tags["http.url"] == "/a/b/baz" span.context().tags["http.url"] == "/a/b/baz"
span.context().tags["http.method"] == "GET" span.context().tags["http.method"] == "GET"
@ -130,7 +130,7 @@ class RatpackTest extends AgentTestRunner {
span.context().operationName == "ratpack.handler" span.context().operationName == "ratpack.handler"
span.context().resourceName == "GET /" span.context().resourceName == "GET /"
span.context().tags["component"] == "handler" span.context().tags["component"] == "handler"
span.context().spanType == DDSpanTypes.WEB_SERVLET span.context().spanType == DDSpanTypes.HTTP_SERVER
span.context().tags["http.url"] == "/" span.context().tags["http.url"] == "/"
span.context().tags["http.method"] == "GET" span.context().tags["http.method"] == "GET"
span.context().tags["span.kind"] == "server" span.context().tags["span.kind"] == "server"
@ -191,7 +191,7 @@ class RatpackTest extends AgentTestRunner {
span.context().operationName == "ratpack.handler" span.context().operationName == "ratpack.handler"
span.context().resourceName == "GET /" span.context().resourceName == "GET /"
span.context().tags["component"] == "handler" span.context().tags["component"] == "handler"
span.context().spanType == DDSpanTypes.WEB_SERVLET span.context().spanType == DDSpanTypes.HTTP_SERVER
!span.context().getErrorFlag() !span.context().getErrorFlag()
span.context().tags["http.url"] == "/" span.context().tags["http.url"] == "/"
span.context().tags["http.method"] == "GET" span.context().tags["http.method"] == "GET"
@ -234,7 +234,7 @@ class RatpackTest extends AgentTestRunner {
nestedSpan.context().operationName == "ratpack.handler" nestedSpan.context().operationName == "ratpack.handler"
nestedSpan.context().resourceName == "GET /nested2" nestedSpan.context().resourceName == "GET /nested2"
nestedSpan.context().tags["component"] == "handler" nestedSpan.context().tags["component"] == "handler"
nestedSpan.context().spanType == DDSpanTypes.WEB_SERVLET nestedSpan.context().spanType == DDSpanTypes.HTTP_SERVER
!nestedSpan.context().getErrorFlag() !nestedSpan.context().getErrorFlag()
nestedSpan.context().tags["http.url"] == "/nested2" nestedSpan.context().tags["http.url"] == "/nested2"
nestedSpan.context().tags["http.method"] == "GET" nestedSpan.context().tags["http.method"] == "GET"
@ -251,7 +251,7 @@ class RatpackTest extends AgentTestRunner {
nestedSpan2.context().operationName == "ratpack.handler" nestedSpan2.context().operationName == "ratpack.handler"
nestedSpan2.context().resourceName == "GET /nested" nestedSpan2.context().resourceName == "GET /nested"
nestedSpan2.context().tags["component"] == "handler" nestedSpan2.context().tags["component"] == "handler"
nestedSpan2.context().spanType == DDSpanTypes.WEB_SERVLET nestedSpan2.context().spanType == DDSpanTypes.HTTP_SERVER
!nestedSpan2.context().getErrorFlag() !nestedSpan2.context().getErrorFlag()
nestedSpan2.context().tags["http.url"] == "/nested" nestedSpan2.context().tags["http.url"] == "/nested"
nestedSpan2.context().tags["http.method"] == "GET" nestedSpan2.context().tags["http.method"] == "GET"

View File

@ -79,14 +79,14 @@ class SparkJavaBasedTest extends AgentTestRunner {
context.serviceName == "unnamed-java-app" context.serviceName == "unnamed-java-app"
context.operationName == "jetty.request" context.operationName == "jetty.request"
context.resourceName == "GET /param/:param" context.resourceName == "GET /param/:param"
context.spanType == DDSpanTypes.WEB_SERVLET context.spanType == DDSpanTypes.HTTP_SERVER
!context.getErrorFlag() !context.getErrorFlag()
context.parentId == "0" context.parentId == "0"
def tags = context.tags def tags = context.tags
tags["http.url"] == "http://localhost:$port/param/asdf1234" tags["http.url"] == "http://localhost:$port/param/asdf1234"
tags["http.method"] == "GET" tags["http.method"] == "GET"
tags["span.kind"] == "server" tags["span.kind"] == "server"
tags["span.type"] == "web" tags["span.type"] == DDSpanTypes.HTTP_SERVER
tags["component"] == "jetty-handler" tags["component"] == "jetty-handler"
tags["http.status_code"] == 200 tags["http.status_code"] == 200
tags["thread.name"] != null tags["thread.name"] != null