Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static datadog.trace.api.cache.RadixTreeCache.UNSET_STATUS;
import static datadog.trace.api.datastreams.DataStreamsContext.forHttpServer;
import static datadog.trace.api.gateway.Events.EVENTS;
import static datadog.trace.bootstrap.instrumentation.api.AgentPropagation.extractContextAndGetSpanContext;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.traceConfig;
import static datadog.trace.bootstrap.instrumentation.decorator.http.HttpResourceDecorator.HTTP_RESOURCE_DECORATOR;

Expand Down Expand Up @@ -119,32 +118,14 @@ protected AgentTracer.TracerAPI tracer() {
return AgentTracer.get();
}

/** Deprecated. Use {@link #extractContext(REQUEST_CARRIER)} instead. */
public AgentSpanContext.Extracted extract(REQUEST_CARRIER carrier) {
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
if (null == carrier || null == getter) {
return null;
}
return extractContextAndGetSpanContext(carrier, getter);
}

/**
* Will be renamed to #extract(REQUEST_CARRIER) when refactoring of instrumentations is complete
*/
public Context extractContext(REQUEST_CARRIER carrier) {
public Context extract(REQUEST_CARRIER carrier) {
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
if (null == carrier || null == getter) {
return root();
}
return Propagators.defaultPropagator().extract(root(), carrier, getter);
}

/** Deprecated. Use {@link #startSpan(Object, Context)} instead. */
@Deprecated
public AgentSpan startSpan(REQUEST_CARRIER carrier, AgentSpanContext.Extracted context) {
return startSpan("http-server", carrier, context);
}

public AgentSpan startSpan(
String instrumentationName, REQUEST_CARRIER carrier, AgentSpanContext.Extracted context) {
AgentSpan span =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class DatadogWrapperHelper {
public static ContextScope createSpan(final HttpRequest request) {
final Context context = DECORATE.extractContext(request);
final Context context = DECORATE.extract(request);
final AgentSpan span = DECORATE.startSpan(request, context);
DECORATE.afterStart(span);
DECORATE.onRequest(span, request, request, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static class AzureFunctionsAdvice {
public static ContextScope methodEnter(
@Advice.Argument(0) final HttpRequestMessage request,
@Advice.Argument(1) final ExecutionContext context) {
final Context extractedContext = DECORATE.extractContext(request);
final Context extractedContext = DECORATE.extract(request);
final AgentSpan span = DECORATE.startSpan(request, extractedContext);
DECORATE.afterStart(span, context.getFunctionName());
DECORATE.onRequest(span, request, request, extractedContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static class HandleAdvice {
return false;
}

final Context parentContext = DECORATE.extractContext(request);
final Context parentContext = DECORATE.extract(request);
final AgentSpan span = DECORATE.startSpan(request, parentContext);
DECORATE.afterStart(span);
DECORATE.onRequest(span, request, request, parentContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static NextAction onHttpCodecFilterExit(
}
HttpRequestPacket httpRequest = (HttpRequestPacket) httpHeader;
HttpResponsePacket httpResponse = httpRequest.getResponse();
Context context = DECORATE.extractContext(httpRequest);
Context context = DECORATE.extract(httpRequest);
AgentSpan span = DECORATE.startSpan(httpRequest, context);
ContextScope scope = context.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static ContextScope onEnter(
return activateSpan((AgentSpan) existingSpan);
}

final Context context = DECORATE.extractContext(req);
final Context context = DECORATE.extract(req);
span = DECORATE.startSpan(req, context);
final ContextScope scope = context.with(span).attach();
span.setMeasured(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void onExit(
}
}

final Context context = JettyDecorator.DECORATE.extractContext(req);
final Context context = JettyDecorator.DECORATE.extract(req);
final AgentSpan span = JettyDecorator.DECORATE.startSpan(req, context);
try (final ContextScope scope = context.with(span).attach()) {
span.setMeasured(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static ContextScope onEnter(
return ((AgentSpan) existingSpan).attach();
}

final Context extractedContext = DECORATE.extractContext(req);
final Context extractedContext = DECORATE.extract(req);
span = DECORATE.startSpan(req, extractedContext);
final ContextScope scope = extractedContext.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static ContextScope onEnter(
return ((AgentSpan) existingSpan).attach();
}

final Context extractedContext = DECORATE.extractContext(req);
final Context extractedContext = DECORATE.extract(req);
span = DECORATE.startSpan(req, extractedContext);
final ContextScope scope = extractedContext.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static ContextScope onEnter(
return ((AgentSpan) existingSpan).attach();
}

final Context context = DECORATE.extractContext(req);
final Context context = DECORATE.extract(req);
span = DECORATE.startSpan(req, context);
final ContextScope scope = context.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static ContextScope onEnter(
return ((AgentSpan) existingSpan).attach();
}

final Context context = DECORATE.extractContext(req);
final Context context = DECORATE.extract(req);
span = DECORATE.startSpan(req, context);
DECORATE.afterStart(span);
DECORATE.onRequest(span, req, req, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static class HandleRequestAdvice {
} catch (NullPointerException e) {
}

final Context context = DECORATE.extractContext(request);
final Context context = DECORATE.extract(request);
request.setAttribute(DD_EXTRACTED_CONTEXT_ATTRIBUTE, context);
final AgentSpan span = DECORATE.startSpan(request, context);
scope = context.with(span).attach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static class HandleRequestAdvice {
} catch (NullPointerException e) {
}

final Context context = DECORATE.extractContext(request);
final Context context = DECORATE.extract(request);
request.setAttribute(DD_EXTRACTED_CONTEXT_ATTRIBUTE, context);
final AgentSpan span = DECORATE.startSpan(request, context);
scope = context.with(span).attach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent

final HttpRequest request = (HttpRequest) msg.getMessage();
final HttpHeaders headers = request.headers();
final Context context = DECORATE.extractContext(headers);
final Context context = DECORATE.extract(headers);
final AgentSpan span = DECORATE.startSpan(headers, context);

channelTraceContext.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) {

final HttpRequest request = (HttpRequest) msg;
final HttpHeaders headers = request.headers();
final Context context = DECORATE.extractContext(headers);
final Context context = DECORATE.extract(headers);
final AgentSpan span = DECORATE.startSpan(headers, context);

try (final ContextScope scope = context.with(span).attach()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) {

final HttpRequest request = (HttpRequest) msg;
final HttpHeaders headers = request.headers();
final Context context = DECORATE.extractContext(headers);
final Context context = DECORATE.extract(headers);
final AgentSpan span = DECORATE.startSpan(headers, context);

try (final ContextScope scope = context.with(span).attach()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class DatadogWrapperHelper {
public static ContextScope createSpan(final HttpRequest request) {
final Context context = DECORATE.extractContext(request);
final Context context = DECORATE.extract(request);
final AgentSpan span = DECORATE.startSpan(request, context);
DECORATE.afterStart(span);
DECORATE.onRequest(span, request, request, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static ContextScope onEnter(@Advice.Argument(0) final Request req) {
final ContextScope scope;
if (activeSpan() == null) {
Headers headers = req.headers();
final Context context = DECORATE.extractContext(headers);
final Context context = DECORATE.extract(headers);
span = DECORATE.startSpan(headers, context);
scope = context.with(span).attach();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static ContextScope onEnter(@Advice.Argument(value = 0, readOnly = false)

if (activeSpan() == null) {
final Headers headers = req.headers();
final Context context = DECORATE.extractContext(headers);
final Context context = DECORATE.extract(headers);
span = DECORATE.startSpan(headers, context);
scope = context.with(span).attach();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static ContextScope onEnter(

if (activeSpan() == null) {
final Headers headers = req.headers();
extractedContext = DECORATE.extractContext(headers);
extractedContext = DECORATE.extract(headers);
span = DECORATE.startSpan(headers, extractedContext);
scope = extractedContext.with(span).attach();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String[] helperClassNames() {
public static class RestletHandleAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static ContextScope beginRequest(@Advice.Argument(0) final HttpExchange exchange) {
Context context = DECORATE.extractContext(exchange);
Context context = DECORATE.extract(exchange);
AgentSpan span = DECORATE.startSpan(exchange, context);
ContextScope scope = context.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static boolean onEnter(
InstrumentationContext.get(ServletResponse.class, Integer.class).put(response, 200);
}

final Context context = DECORATE.extractContext(httpServletRequest);
final Context context = DECORATE.extract(httpServletRequest);
final AgentSpan span = DECORATE.startSpan(httpServletRequest, context);
scope = context.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static boolean onEnter(
return false;
}

final Context context = DECORATE.extractContext(httpServletRequest);
final Context context = DECORATE.extract(httpServletRequest);
final AgentSpan span = DECORATE.startSpan(httpServletRequest, context);
scope = context.with(span).attach();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static ContextScope enter(
// Propagate context in case income request was going through several routes
// TODO: Add test for it
final HttpRequest request = ctx.request();
Context extractedContext = DECORATE.extractContext(request);
Context extractedContext = DECORATE.extract(request);
extractedSpanContext = DECORATE.getExtractedSpanContext(extractedContext);
span = DECORATE.startSpan(request, extractedContext);
context = extractedContext.with(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static ContextScope beginRequest(

// check incoming request for distributed trace ids
HttpRequest request = connection.getHttpRequest();
Context context = DECORATE.extractContext(request);
Context context = DECORATE.extract(request);

AgentSpan span;
if (null != context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static ContextScope onService(@Advice.Argument(0) org.apache.coyote.Reque
return activateSpan((AgentSpan) existingSpan);
}

final Context extractedContext = DECORATE.extractContext(req);
final Context extractedContext = DECORATE.extract(req);
// TODO: Migrate setting DD_EXTRACTED_CONTEXT_ATTRIBUTE from AgentSpanContext.Extracted to
// Context
req.setAttribute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void onEnter(
return;
}

final Context extractedContext = DECORATE.extractContext(exchange);
final Context extractedContext = DECORATE.extract(exchange);
final AgentSpan span = DECORATE.startSpan(exchange, extractedContext).setMeasured(true);
scope = extractedContext.with(span).attach();
DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void afterRequestParse(
ContextScope scope = null;
try {
if (span == null) {
final Context context = DECORATE.extractContext(exchange);
final Context context = DECORATE.extract(exchange);
span = DECORATE.startSpan(exchange, context).setMeasured(true);
scope = context.with(span).attach();
DECORATE.afterStart(span);
Expand Down