Skip to content

Disable data streams http & grpc instrumentations by default #7839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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 @@ -22,6 +22,8 @@

public abstract class HttpClientDecorator<REQUEST, RESPONSE> extends UriBasedClientDecorator {
public static final LinkedHashMap<String, String> CLIENT_PATHWAY_EDGE_TAGS;
public static final boolean SHOULD_INSTRUMENT_DATA_STREAMS =
Config.get().isHttpDataStreamsEnabled();

static {
CLIENT_PATHWAY_EDGE_TAGS = new LinkedHashMap<>(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE, REQUEST
&& Config.get().isRuleEnabled("Status404Decorator");
private static final boolean SHOULD_SET_URL_RESOURCE_NAME =
Config.get().isRuleEnabled("URLAsResourceNameRule");
private static final boolean SHOULD_INSTRUMENT_DATA_STREAMS =
Config.get().isHttpDataStreamsEnabled();

private static final BitSet SERVER_ERROR_STATUSES = Config.get().getHttpServerErrorStatuses();

Expand Down Expand Up @@ -146,7 +148,7 @@ public AgentSpan startSpan(
span.setRequestBlockingAction((Flow.Action.RequestBlockingAction) flow.getAction());
}
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
if (null != carrier && null != getter) {
if (null != carrier && null != getter && SHOULD_INSTRUMENT_DATA_STREAMS) {
tracer().getDataStreamsMonitoring().setCheckpoint(span, SERVER_PATHWAY_EDGE_TAGS, 0, 0);
}
return span;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ public static AgentScope methodEnter(

if (request != null) {
propagate().inject(span, request, headers);
propagate()
.injectPathwayContext(
span, request, headers, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request, headers, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
// Request is immutable, so we have to assign new value once we update headers
request = headers.getRequest();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public static AgentScope methodEnter(

if (request != null) {
propagate().inject(span, request, headers);
propagate()
.injectPathwayContext(
span, request, headers, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request, headers, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
// Request is immutable, so we have to assign new value once we update headers
request = headers.getRequest();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public HttpRequest generateRequest() throws IOException, HttpException {
DECORATE.onRequest(span, new HostAndRequestAsHttpUriRequest(delegate.getTarget(), request));

propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}

return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ private static AgentScope activateHttpSpan(final HttpUriRequest request) {
// AWS calls are often signed, so we can't add headers without breaking the signature.
if (!awsClientCall) {
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
}

return scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public void sendRequest(HttpRequest request, EntityDetails entityDetails, HttpCo
DECORATE.onRequest(span, request);

propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
delegate.sendRequest(request, entityDetails, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ private static AgentScope activateHttpSpan(final HttpRequest request) {
// AWS calls are often signed, so we can't add headers without breaking the signature.
if (!awsClientCall) {
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
}

return scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.armeria.grpc.client.GrpcClientDecorator.CLIENT_PATHWAY_EDGE_TAGS;
import static datadog.trace.instrumentation.armeria.grpc.client.GrpcClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS;
import static datadog.trace.instrumentation.armeria.grpc.client.GrpcClientDecorator.DECORATE;
import static datadog.trace.instrumentation.armeria.grpc.client.GrpcClientDecorator.GRPC_MESSAGE;
import static datadog.trace.instrumentation.armeria.grpc.client.GrpcClientDecorator.OPERATION_NAME;
Expand All @@ -19,10 +20,12 @@
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.agent.tooling.muzzle.Reference;
import datadog.trace.api.Config;
import datadog.trace.api.InstrumenterConfig;
import datadog.trace.bootstrap.InstrumentationContext;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.decorator.HttpClientDecorator;
import io.grpc.ClientCall;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
Expand Down Expand Up @@ -121,7 +124,9 @@ public static <T> AgentScope before(
span = InstrumentationContext.get(ClientCall.class, AgentSpan.class).get(call);
if (null != span) {
propagate().inject(span, headers, SETTER);
propagate().injectPathwayContext(span, headers, SETTER, CLIENT_PATHWAY_EDGE_TAGS);
if (SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate().injectPathwayContext(span, headers, SETTER, CLIENT_PATHWAY_EDGE_TAGS);
}
return activateSpan(span);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ private static LinkedHashMap<String, String> createClientPathwaySortedTags() {

public static final LinkedHashMap<String, String> CLIENT_PATHWAY_EDGE_TAGS =
createClientPathwaySortedTags();
public static final boolean SHOULD_INSTRUMENT_DATA_STREAMS =
Config.get().isGrpcDataStreamsEnabled();

public static final GrpcClientDecorator DECORATE = new GrpcClientDecorator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class TracingServerInterceptor implements ServerInterceptor {

public static final TracingServerInterceptor INSTANCE = new TracingServerInterceptor();
private static final Set<String> IGNORED_METHODS = Config.get().getGrpcIgnoredInboundMethods();
private static final boolean SHOULD_INSTRUMENT_DATA_STREAMS =
Config.get().isGrpcDataStreamsEnabled();

private TracingServerInterceptor() {}

Expand All @@ -69,9 +71,11 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
final AgentSpan span =
startSpan(DECORATE.instrumentationNames()[0], GRPC_SERVER, spanContext).setMeasured(true);

AgentTracer.get()
.getDataStreamsMonitoring()
.setCheckpoint(span, SERVER_PATHWAY_EDGE_TAGS, 0, 0);
if (SHOULD_INSTRUMENT_DATA_STREAMS) {
AgentTracer.get()
.getDataStreamsMonitoring()
.setCheckpoint(span, SERVER_PATHWAY_EDGE_TAGS, 0, 0);
}

RequestContext reqContext = span.getRequestContext();
if (reqContext != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ public static AgentScope methodEnter(@Advice.Argument(1) final HttpMethod httpMe
DECORATE.afterStart(span);
DECORATE.onRequest(span, httpMethod);
propagate().inject(span, httpMethod, SETTER);
propagate()
.injectPathwayContext(
span, httpMethod, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, httpMethod, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}

return scope;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public AgentSpan prepareSpan(AgentSpan span, HttpRequest request) {
DECORATE.afterStart(span);
DECORATE.onRequest(span, request);
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
return span;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ public static void onEnter(
DECORATE.afterStart(span);
DECORATE.onRequest(span, request);
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
handler = new AsyncHandlerAdapter<>(span, parentSpan, handler);
}
}
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.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
import static datadog.trace.instrumentation.grpc.client.GrpcClientDecorator.CLIENT_PATHWAY_EDGE_TAGS;
import static datadog.trace.instrumentation.grpc.client.GrpcClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS;
import static datadog.trace.instrumentation.grpc.client.GrpcClientDecorator.DECORATE;
import static datadog.trace.instrumentation.grpc.client.GrpcInjectAdapter.SETTER;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
Expand All @@ -16,6 +17,7 @@
import datadog.trace.bootstrap.InstrumentationContext;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.decorator.HttpClientDecorator;
import io.grpc.ClientCall;
import io.grpc.Grpc;
import io.grpc.Metadata;
Expand Down Expand Up @@ -93,7 +95,9 @@ public static AgentScope before(
span = InstrumentationContext.get(ClientCall.class, AgentSpan.class).get(call);
if (null != span) {
propagate().inject(span, headers, SETTER);
propagate().injectPathwayContext(span, headers, SETTER, CLIENT_PATHWAY_EDGE_TAGS);
if (SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate().injectPathwayContext(span, headers, SETTER, CLIENT_PATHWAY_EDGE_TAGS);
}
return activateSpan(span);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ private static LinkedHashMap<String, String> createClientPathwaySortedTags() {

public static final LinkedHashMap<String, String> CLIENT_PATHWAY_EDGE_TAGS =
createClientPathwaySortedTags();
public static final boolean SHOULD_INSTRUMENT_DATA_STREAMS =
Config.get().isGrpcDataStreamsEnabled();

public static final GrpcClientDecorator DECORATE = new GrpcClientDecorator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class TracingServerInterceptor implements ServerInterceptor {

public static final TracingServerInterceptor INSTANCE = new TracingServerInterceptor();
private static final Set<String> IGNORED_METHODS = Config.get().getGrpcIgnoredInboundMethods();
private static final boolean SHOULD_INSTRUMENT_DATA_STREAMS =
Config.get().isGrpcDataStreamsEnabled();

private TracingServerInterceptor() {}

Expand All @@ -68,9 +70,11 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
CallbackProvider cbp = tracer.getCallbackProvider(RequestContextSlot.APPSEC);
final AgentSpan span = startSpan(GRPC_SERVER, spanContext).setMeasured(true);

AgentTracer.get()
.getDataStreamsMonitoring()
.setCheckpoint(span, SERVER_PATHWAY_EDGE_TAGS, 0, 0);
if (SHOULD_INSTRUMENT_DATA_STREAMS) {
AgentTracer.get()
.getDataStreamsMonitoring()
.setCheckpoint(span, SERVER_PATHWAY_EDGE_TAGS, 0, 0);
}

RequestContext reqContext = span.getRequestContext();
if (reqContext != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ public static HttpUrlState methodEnter(
final AgentSpan span = state.start(thiz);
if (!connected) {
propagate().inject(span, thiz, SETTER);
propagate()
.injectPathwayContext(
span, thiz, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, thiz, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
}
}
return state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public static void methodExit(@Advice.Return(readOnly = false) HttpHeaders heade
final Map<String, List<String>> headerMap = new HashMap<>(headers.map());
final AgentSpan span = activeSpan();
propagate().inject(span, headerMap, SETTER);
propagate()
.injectPathwayContext(
span, headerMap, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, headerMap, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
headers = HttpHeaders.of(headerMap, KEEP);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ public static AgentScope onEnter(
request.getProperties().put(DD_SPAN_ATTRIBUTE, span);

propagate().inject(span, request.getHeaders(), SETTER);
propagate()
.injectPathwayContext(
span, request.getHeaders(), SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request.getHeaders(), SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
return activateSpan(span);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public void filter(final ClientRequestContext requestContext) {
DECORATE.onRequest(span, requestContext);

propagate().inject(span, requestContext.getHeaders(), SETTER);
propagate()
.injectPathwayContext(
span,
requestContext.getHeaders(),
SETTER,
HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span,
requestContext.getHeaders(),
SETTER,
HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}

requestContext.setProperty(SPAN_PROPERTY_NAME, span);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public static AgentSpan methodEnter(
DECORATE.afterStart(span);
DECORATE.onRequest(span, request);
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
return span;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public static AgentScope methodEnter(@Advice.This final HttpRequest request) {
JettyClientDecorator.DECORATE.afterStart(span);
JettyClientDecorator.DECORATE.onRequest(span, request);
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
return activateSpan(span);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ public static AgentSpan methodEnter(
DECORATE.afterStart(span);
DECORATE.onRequest(span, request);
propagate().inject(span, request, SETTER);
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
if (HttpClientDecorator.SHOULD_INSTRUMENT_DATA_STREAMS) {
propagate()
.injectPathwayContext(
span, request, SETTER, HttpClientDecorator.CLIENT_PATHWAY_EDGE_TAGS);
}
return span;
}

Expand Down
Loading