Merge pull request #755 from DataDog/tyler/stop-aws-inject

Remove trace injection into AWS requests
This commit is contained in:
Tyler Benson 2019-03-12 14:52:50 -07:00 committed by GitHub
commit e5d9507636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 31 deletions

View File

@ -8,8 +8,6 @@ import com.amazonaws.Response;
import com.amazonaws.handlers.HandlerContextKey;
import com.amazonaws.handlers.RequestHandler2;
import io.opentracing.Scope;
import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMapInjectAdapter;
import io.opentracing.util.GlobalTracer;
/** Tracing Request Handler */
@ -31,15 +29,6 @@ public class TracingRequestHandler extends RequestHandler2 {
final Scope scope = GlobalTracer.get().buildSpan("aws.command").startActive(true);
DECORATE.afterStart(scope.span());
DECORATE.onRequest(scope.span(), request);
// We inject headers at aws-client level because aws requests may be signed and adding headers
// on http-client level may break signature.
GlobalTracer.get()
.inject(
scope.span().context(),
Format.Builtin.HTTP_HEADERS,
new TextMapInjectAdapter(request.getHeaders()));
request.addHandlerContext(SCOPE_CONTEXT_KEY, scope);
}

View File

@ -113,8 +113,8 @@ class AWSClientTest extends AgentTestRunner {
}
}
}
server.lastRequest.headers.get("x-datadog-trace-id") == TEST_WRITER[0][0].traceId
server.lastRequest.headers.get("x-datadog-parent-id") == TEST_WRITER[0][0].spanId
server.lastRequest.headers.get("x-datadog-trace-id") == null
server.lastRequest.headers.get("x-datadog-parent-id") == null
where:
service | operation | method | url | handlerCount | call | body | client

View File

@ -142,8 +142,8 @@ class AWSClientTest extends AgentTestRunner {
}
}
}
server.lastRequest.headers.get("x-datadog-trace-id") == TEST_WRITER[0][0].traceId
server.lastRequest.headers.get("x-datadog-parent-id") == TEST_WRITER[0][0].spanId
server.lastRequest.headers.get("x-datadog-trace-id") == null
server.lastRequest.headers.get("x-datadog-parent-id") == null
where:
service | operation | method | url | handlerCount | call | body | client

View File

@ -5,8 +5,6 @@ import static datadog.trace.instrumentation.aws.v2.AwsSdkClientDecorator.DECORAT
import datadog.trace.context.TraceScope;
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMap;
import io.opentracing.util.GlobalTracer;
import java.util.Iterator;
@ -49,16 +47,6 @@ public class TracingExecutionInterceptor implements ExecutionInterceptor {
DECORATE.onAttributes(span, executionAttributes);
}
@Override
public SdkHttpRequest modifyHttpRequest(
final Context.ModifyHttpRequest context, final ExecutionAttributes executionAttributes) {
final Tracer tracer = GlobalTracer.get();
final Span span = executionAttributes.getAttribute(SPAN_ATTRIBUTE);
final SdkHttpRequest.Builder builder = context.httpRequest().toBuilder();
tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new InjectAdapter(builder));
return builder.build();
}
@Override
public void beforeTransmission(
final Context.BeforeTransmission context, final ExecutionAttributes executionAttributes) {

View File

@ -105,8 +105,8 @@ class AwsClientTest extends AgentTestRunner {
}
}
}
server.lastRequest.headers.get("x-datadog-trace-id") == TEST_WRITER[0][0].traceId
server.lastRequest.headers.get("x-datadog-parent-id") == TEST_WRITER[0][0].spanId
server.lastRequest.headers.get("x-datadog-trace-id") == null
server.lastRequest.headers.get("x-datadog-parent-id") == null
where:
service | operation | method | path | requestId | call | body | builder
@ -202,8 +202,8 @@ class AwsClientTest extends AgentTestRunner {
}
}
}
server.lastRequest.headers.get("x-datadog-trace-id") == TEST_WRITER[0][0].traceId
server.lastRequest.headers.get("x-datadog-parent-id") == TEST_WRITER[0][0].spanId
server.lastRequest.headers.get("x-datadog-trace-id") == null
server.lastRequest.headers.get("x-datadog-parent-id") == null
where:
service | operation | method | path | requestId | call | body | builder