Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstartin committed May 14, 2020
1 parent dc170af commit ca7ab34
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package datadog.trace.bootstrap.instrumentation.api;

public class Pair<T, U> {
public final class Pair<T, U> {

public static <T, U> Pair<T, U> of(T left, U right) {
return new Pair<>(left, right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -43,7 +44,7 @@ class GrizzlyTest extends HttpServerTest<HttpServer> {

@Override
String expectedOperationName() {
return "grizzly.request"
return DDSpanNames.GRIZZLY_REQUEST;
}

static class SimpleExceptionMapper implements ExceptionMapper<Throwable> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,7 +19,7 @@ protected String[] instrumentationNames() {

@Override
protected String component() {
return "grizzly-http-async-client";
return GRIZZLY_HTTP_ASYNC_CLIENT;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -60,7 +61,7 @@ class GrizzlyFilterchainServerTest extends HttpServerTest<HttpServer> {

@Override
String expectedOperationName() {
return "http.request"
return DDSpanNames.GRIZZLY_REQUEST
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit ca7ab34

Please sign in to comment.