From ca7ab34ccbbb13c14addd60f79df77ac37e0c813 Mon Sep 17 00:00:00 2001 From: Richard Startin Date: Thu, 14 May 2020 10:16:30 +0100 Subject: [PATCH] address review comments --- .../datadog/trace/bootstrap/instrumentation/api/Pair.java | 2 +- .../grizzly/GrizzlyHttpHandlerInstrumentation.java | 3 ++- .../grizzly-2/src/test/groovy/GrizzlyTest.groovy | 3 ++- .../mulehttpconnector/client/ClientDecorator.java | 4 +++- .../mulehttpconnector/client/ClientRequestAdvice.java | 3 ++- .../mulehttpconnector/server/ServerDecorator.java | 6 ++++-- .../src/test/groovy/GrizzlyFilterchainServerTest.groovy | 3 ++- .../src/main/java/datadog/trace/core/StringTables.java | 2 ++ .../trace/bootstrap/instrumentation/api/DDComponents.java | 2 ++ .../trace/bootstrap/instrumentation/api/DDSpanNames.java | 6 ++++++ 10 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDSpanNames.java diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/api/Pair.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/api/Pair.java index 02d13da7011..7b5f1af936b 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/api/Pair.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/api/Pair.java @@ -1,6 +1,6 @@ package datadog.trace.bootstrap.instrumentation.api; -public class Pair { +public final class Pair { public static Pair of(T left, U right) { return new Pair<>(left, right); diff --git a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java index 86e2ac208df..b67b73010c6 100644 --- a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java +++ b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java @@ -3,6 +3,7 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; +import static datadog.trace.bootstrap.instrumentation.api.DDSpanNames.GRIZZLY_REQUEST; import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_SPAN_ATTRIBUTE; import static datadog.trace.instrumentation.grizzly.GrizzlyDecorator.DECORATE; import static datadog.trace.instrumentation.grizzly.GrizzlyRequestExtractAdapter.GETTER; @@ -71,7 +72,7 @@ public static AgentScope methodEnter(@Advice.Argument(0) final Request request) } final Context parentContext = propagate().extract(request, GETTER); - final AgentSpan span = startSpan("grizzly.request", parentContext); + final AgentSpan span = startSpan(GRIZZLY_REQUEST, parentContext); DECORATE.afterStart(span); DECORATE.onConnection(span, request); DECORATE.onRequest(span, request); diff --git a/dd-java-agent/instrumentation/grizzly-2/src/test/groovy/GrizzlyTest.groovy b/dd-java-agent/instrumentation/grizzly-2/src/test/groovy/GrizzlyTest.groovy index ebaadf91f18..81d6b709b95 100644 --- a/dd-java-agent/instrumentation/grizzly-2/src/test/groovy/GrizzlyTest.groovy +++ b/dd-java-agent/instrumentation/grizzly-2/src/test/groovy/GrizzlyTest.groovy @@ -1,4 +1,5 @@ import datadog.trace.agent.test.base.HttpServerTest +import datadog.trace.bootstrap.instrumentation.api.DDSpanNames import datadog.trace.instrumentation.grizzly.GrizzlyDecorator import org.glassfish.grizzly.http.server.HttpServer import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory @@ -43,7 +44,7 @@ class GrizzlyTest extends HttpServerTest { @Override String expectedOperationName() { - return "grizzly.request" + return DDSpanNames.GRIZZLY_REQUEST; } static class SimpleExceptionMapper implements ExceptionMapper { diff --git a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientDecorator.java b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientDecorator.java index 75aca166623..40c8b2743b4 100644 --- a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientDecorator.java +++ b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientDecorator.java @@ -1,5 +1,7 @@ package datadog.trace.instrumentation.mulehttpconnector.client; +import static datadog.trace.bootstrap.instrumentation.api.DDComponents.GRIZZLY_HTTP_ASYNC_CLIENT; + import com.ning.http.client.Request; import com.ning.http.client.Response; import datadog.trace.bootstrap.instrumentation.decorator.HttpClientDecorator; @@ -17,7 +19,7 @@ protected String[] instrumentationNames() { @Override protected String component() { - return "grizzly-http-async-client"; + return GRIZZLY_HTTP_ASYNC_CLIENT; } @Override diff --git a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientRequestAdvice.java b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientRequestAdvice.java index e37b817f2a3..245af1828e5 100644 --- a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientRequestAdvice.java +++ b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/client/ClientRequestAdvice.java @@ -4,6 +4,7 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; +import static datadog.trace.bootstrap.instrumentation.api.DDSpanNames.GRIZZLY_REQUEST; import static datadog.trace.instrumentation.mulehttpconnector.client.ClientDecorator.DECORATE; import static datadog.trace.instrumentation.mulehttpconnector.client.InjectAdapter.SETTER; @@ -23,7 +24,7 @@ public static AgentScope onEnter( @Advice.Argument(0) final Request request, @Advice.Argument(1) final AsyncHandler handler) { AgentSpan parentSpan = activeSpan(); - AgentSpan span = startSpan("http.request"); + AgentSpan span = startSpan(GRIZZLY_REQUEST); DECORATE.afterStart(span); DECORATE.onRequest(span, request); propagate().inject(span, request, SETTER); diff --git a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/server/ServerDecorator.java b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/server/ServerDecorator.java index 26efb581d54..43d3cd4652d 100644 --- a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/server/ServerDecorator.java +++ b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/main/java/datadog/trace/instrumentation/mulehttpconnector/server/ServerDecorator.java @@ -3,6 +3,8 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; +import static datadog.trace.bootstrap.instrumentation.api.DDComponents.GRIZZLY_FILTER_CHAIN_SERVER; +import static datadog.trace.bootstrap.instrumentation.api.DDSpanNames.GRIZZLY_REQUEST; import static datadog.trace.instrumentation.mulehttpconnector.server.ExtractAdapter.GETTER; import datadog.trace.bootstrap.instrumentation.api.AgentScope; @@ -58,7 +60,7 @@ protected String[] instrumentationNames() { @Override protected String component() { - return "grizzly-filterchain-server"; + return GRIZZLY_FILTER_CHAIN_SERVER; } public static void onHttpCodecFilterExit(FilterChainContext ctx, HttpHeader httpHeader) { @@ -70,7 +72,7 @@ public static void onHttpCodecFilterExit(FilterChainContext ctx, HttpHeader http } HttpRequestPacket httpRequest = (HttpRequestPacket) httpHeader; HttpResponsePacket httpResponse = httpRequest.getResponse(); - AgentSpan span = startSpan("http.request", propagate().extract(httpHeader, GETTER)); + AgentSpan span = startSpan(GRIZZLY_REQUEST, propagate().extract(httpHeader, GETTER)); AgentScope scope = activateSpan(span); scope.setAsyncPropagation(true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy index 60d13514a50..6523a0c7713 100644 --- a/dd-java-agent/instrumentation/mule-http-connector-1.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy +++ b/dd-java-agent/instrumentation/mule-http-connector-1.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy @@ -1,4 +1,5 @@ import datadog.trace.agent.test.base.HttpServerTest +import datadog.trace.bootstrap.instrumentation.api.DDSpanNames import datadog.trace.instrumentation.mulehttpconnector.server.ServerDecorator import org.glassfish.grizzly.filterchain.BaseFilter import org.glassfish.grizzly.filterchain.FilterChain @@ -60,7 +61,7 @@ class GrizzlyFilterchainServerTest extends HttpServerTest { @Override String expectedOperationName() { - return "http.request" + return DDSpanNames.GRIZZLY_REQUEST } @Override diff --git a/dd-trace-core/src/main/java/datadog/trace/core/StringTables.java b/dd-trace-core/src/main/java/datadog/trace/core/StringTables.java index 6a804697688..2565b364d84 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/StringTables.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/StringTables.java @@ -4,6 +4,7 @@ import datadog.trace.api.DDSpanTypes; import datadog.trace.bootstrap.instrumentation.api.DDComponents; +import datadog.trace.bootstrap.instrumentation.api.DDSpanNames; import datadog.trace.bootstrap.instrumentation.api.Tags; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -36,6 +37,7 @@ public class StringTables { internConstantsUTF8(Tags.class); internConstantsUTF8(DDSpanTypes.class); internConstantsUTF8(DDComponents.class); + internConstantsUTF8(DDSpanNames.class); } public static byte[] getBytesUTF8(String value) { diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDComponents.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDComponents.java index 5265a0e239d..6f63b883564 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDComponents.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDComponents.java @@ -49,4 +49,6 @@ public class DDComponents { public static final String SPRING_SCHEDULING = "spring-scheduling"; public static final String SPRING_WEB_CONTROLLER = "spring-web-controller"; public static final String JAVA_SPY_MEMCACHED = "java-spymemcached"; + public static final String GRIZZLY_HTTP_ASYNC_CLIENT = "grizzly-http-async-client"; + public static final String GRIZZLY_FILTER_CHAIN_SERVER = "grizzly-filterchain-server"; } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDSpanNames.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDSpanNames.java new file mode 100644 index 00000000000..ba2aa4c2997 --- /dev/null +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/DDSpanNames.java @@ -0,0 +1,6 @@ +package datadog.trace.bootstrap.instrumentation.api; + +public class DDSpanNames { + public static final String HTTP_REQUEST = "http.request"; + public static final String GRIZZLY_REQUEST = "grizzly.request"; +}