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 @@ -82,6 +82,8 @@ private fun registerLogEnvVarUsages(target: Project, extension: SupportedTracerC
val javaFiles = target.fileTree(target.projectDir) {
include("**/src/main/java/**/*.java")
exclude("**/build/**", "**/dd-smoke-tests/**")
// Undertow uses DD_UNDERTOW_CONTINUATION as a legacy key to store an AgentScope. It is not related to an environment variable
exclude("dd-java-agent/instrumentation/undertow/src/main/java/datadog/trace/instrumentation/undertow/UndertowDecorator.java")
}
inputs.files(javaFiles)
outputs.upToDateWhen { true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package datadog.trace.instrumentation.undertow;

import static datadog.trace.instrumentation.undertow.UndertowDecorator.DD_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DATADOG_UNDERTOW_CONTINUATION;

import datadog.appsec.api.blocking.BlockingContentType;
import datadog.trace.api.gateway.Flow;
Expand Down Expand Up @@ -117,7 +117,7 @@ private static void commitBlockingResponse(
}

private static void markAsEffectivelyBlocked(HttpServerExchange xchg) {
AgentScope.Continuation continuation = xchg.getAttachment(DD_UNDERTOW_CONTINUATION);
AgentScope.Continuation continuation = xchg.getAttachment(DATADOG_UNDERTOW_CONTINUATION);
if (continuation != null) {
continuation.span().getRequestContext().getTraceSegment().effectivelyBlocked();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class UndertowDecorator
InstanceStore.of(AttachmentKey.class);

@SuppressWarnings("unchecked")
public static final AttachmentKey<AgentScope.Continuation> DD_UNDERTOW_CONTINUATION =
public static final AttachmentKey<AgentScope.Continuation> DATADOG_UNDERTOW_CONTINUATION =
attachmentStore.putIfAbsent(
"DD_UNDERTOW_CONTINUATION", () -> AttachmentKey.create(AgentScope.Continuation.class));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package datadog.trace.instrumentation.undertow;

import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DD_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DATADOG_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DECORATE;

import datadog.context.Context;
Expand All @@ -18,7 +18,7 @@ private ExchangeEndSpanListener() {}

@Override
public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) {
AgentScope.Continuation continuation = exchange.getAttachment(DD_UNDERTOW_CONTINUATION);
AgentScope.Continuation continuation = exchange.getAttachment(DATADOG_UNDERTOW_CONTINUATION);
if (continuation == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.undertow.UndertowBlockingHandler.REQUEST_BLOCKING_DATA;
import static datadog.trace.instrumentation.undertow.UndertowBlockingHandler.TRACE_SEGMENT;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DD_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DATADOG_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DECORATE;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
Expand Down Expand Up @@ -87,7 +87,7 @@ public static void onEnter(
}
}

AgentScope.Continuation continuation = exchange.getAttachment(DD_UNDERTOW_CONTINUATION);
AgentScope.Continuation continuation = exchange.getAttachment(DATADOG_UNDERTOW_CONTINUATION);
if (continuation != null) {
// not yet complete, not ready to do final activation of continuation
scope = continuation.span().attach();
Expand All @@ -101,7 +101,7 @@ public static void onEnter(
DECORATE.afterStart(span);
DECORATE.onRequest(span, exchange, exchange, parentContext);

exchange.putAttachment(DD_UNDERTOW_CONTINUATION, captureSpan(span));
exchange.putAttachment(DATADOG_UNDERTOW_CONTINUATION, captureSpan(span));

exchange.addExchangeCompleteListener(ExchangeEndSpanListener.INSTANCE);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package datadog.trace.instrumentation.undertow;

import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DD_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DATADOG_UNDERTOW_CONTINUATION;
import static net.bytebuddy.matcher.ElementMatchers.isPrivate;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
Expand Down Expand Up @@ -62,7 +62,7 @@ static class GetResponseChannelAdvice {
return false;
}

AgentScope.Continuation continuation = xchg.getAttachment(DD_UNDERTOW_CONTINUATION);
AgentScope.Continuation continuation = xchg.getAttachment(DATADOG_UNDERTOW_CONTINUATION);
if (continuation == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.SERVLET_PATH;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
import static datadog.trace.bootstrap.instrumentation.decorator.http.HttpResourceDecorator.HTTP_RESOURCE_DECORATOR;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DD_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DATADOG_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.SERVLET_REQUEST;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

Expand Down Expand Up @@ -64,7 +64,7 @@ public static class DispatchAdvice {
public static void enter(
@Advice.Argument(0) final HttpServerExchange exchange,
@Advice.Argument(1) final ServletRequestContext servletRequestContext) {
AgentScope.Continuation continuation = exchange.getAttachment(DD_UNDERTOW_CONTINUATION);
AgentScope.Continuation continuation = exchange.getAttachment(DATADOG_UNDERTOW_CONTINUATION);
if (continuation != null) {
AgentSpan undertowSpan = continuation.span();
ServletRequest request = servletRequestContext.getServletRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.SERVLET_CONTEXT;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.SERVLET_PATH;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DD_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.DATADOG_UNDERTOW_CONTINUATION;
import static datadog.trace.instrumentation.undertow.UndertowDecorator.SERVLET_REQUEST;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

Expand Down Expand Up @@ -56,7 +56,7 @@ public static class DispatchAdvice {
public static void enter(
@Advice.Argument(0) final HttpServerExchange exchange,
@Advice.Argument(1) final ServletRequestContext servletRequestContext) {
AgentScope.Continuation continuation = exchange.getAttachment(DD_UNDERTOW_CONTINUATION);
AgentScope.Continuation continuation = exchange.getAttachment(DATADOG_UNDERTOW_CONTINUATION);
if (continuation != null) {
AgentSpan undertowSpan = continuation.span();
ServletRequest request = servletRequestContext.getServletRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ public final class ConfigDefaults {
static final boolean DEFAULT_ELASTICSEARCH_BODY_ENABLED = false;
static final boolean DEFAULT_ELASTICSEARCH_PARAMS_ENABLED = true;
static final boolean DEFAULT_ELASTICSEARCH_BODY_AND_PARAMS_ENABLED = false;
static final boolean DEFAULT_ADD_SPAN_POINTERS = true;

static final boolean DEFAULT_SPARK_TASK_HISTOGRAM_ENABLED = true;
static final boolean DEFAULT_SPARK_APP_NAME_AS_SERVICE = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ public final class AppSecConfig {
public static final String APPSEC_MAX_STACK_TRACE_DEPTH = "appsec.max.stack-trace.depth";
public static final String APPSEC_MAX_STACKTRACE_DEPTH_DEPRECATED =
"appsec.max.stacktrace.depth"; // old non-standard as a fallback alias
@Deprecated public static final String APPSEC_COLLECT_ALL_HEADERS = "appsec.collect.all.headers";

@Deprecated
public static final String APPSEC_MAX_COLLECTED_HEADERS = "appsec.max.collected.headers";

@Deprecated
public static final String APPSEC_HEADER_COLLECTION_REDACTION_ENABLED =
"appsec.header.collection.redaction.enabled";

@Deprecated
public static final String APPSEC_RASP_COLLECT_REQUEST_BODY = "appsec.rasp.collect.request.body";

private AppSecConfig() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public final class ProfilingConfig {
public static final String PROFILING_BACKPRESSURE_SAMPLING_ENABLED =
"profiling.backpressure.sampling.enabled";
public static final boolean PROFILING_BACKPRESSURE_SAMPLING_ENABLED_DEFAULT = false;
public static final String PROFILING_BACKPRESSURE_SAMPLE_LIMIT =
"profiling.backpressure.sample.limit";

public static final int PROFILING_BACKPRESSURE_SAMPLE_LIMIT_DEFAULT = 10_000;

public static final String PROFILING_DIRECT_ALLOCATION_SAMPLE_LIMIT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public final class TraceInstrumentationConfig {
public static final String EXPERIMENTAL_DEFER_INTEGRATIONS_UNTIL =
"experimental.defer.integrations.until";

@SuppressWarnings("unused")
public static final String TRACE_TESTS_ENABLED = "trace.tests.enabled";

public static final String TRACE_THREAD_POOL_EXECUTORS_EXCLUDE =
"trace.thread-pool-executors.exclude";

Expand Down Expand Up @@ -198,7 +195,6 @@ public final class TraceInstrumentationConfig {
public static final String AXIS_PROMOTE_RESOURCE_NAME = "trace.axis.promote.resource-name";

public static final String SQS_BODY_PROPAGATION_ENABLED = "trace.sqs.body.propagation.enabled";
public static final String ADD_SPAN_POINTERS = "add.span.pointers";

private TraceInstrumentationConfig() {}
}
8 changes: 1 addition & 7 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static datadog.environment.JavaVirtualMachine.isJavaVersion;
import static datadog.environment.JavaVirtualMachine.isJavaVersionAtLeast;
import static datadog.trace.api.ConfigDefaults.DEFAULT_ADD_SPAN_POINTERS;
import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_HOST;
import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_TIMEOUT;
import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_WRITER_TYPE;
Expand Down Expand Up @@ -519,7 +518,6 @@
import static datadog.trace.api.config.RumConfig.RUM_TRACK_RESOURCES;
import static datadog.trace.api.config.RumConfig.RUM_TRACK_USER_INTERACTION;
import static datadog.trace.api.config.RumConfig.RUM_VERSION;
import static datadog.trace.api.config.TraceInstrumentationConfig.ADD_SPAN_POINTERS;
import static datadog.trace.api.config.TraceInstrumentationConfig.AXIS_PROMOTE_RESOURCE_NAME;
import static datadog.trace.api.config.TraceInstrumentationConfig.CASSANDRA_KEYSPACE_STATEMENT_EXTRACTION_ENABLED;
import static datadog.trace.api.config.TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED;
Expand Down Expand Up @@ -5262,11 +5260,7 @@ public boolean isTimeInQueueEnabled(
}

public boolean isAddSpanPointers(final String integrationName) {
return configProvider.isEnabled(
Collections.singletonList(ADD_SPAN_POINTERS),
integrationName,
"",
DEFAULT_ADD_SPAN_POINTERS);
return configProvider.isEnabled(Arrays.asList(integrationName), "", "add.span.pointers", true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it make sense to extend configProvider.isEnabled() to accept single name?
I can see a lot of places in code wrapping string into list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can definitely be refactored to have a function that takes in the array to call another function take in a single name, but IMO that's out of scope for this PR and should be introduced in a follow-up. I can handle that when I have a chance in the future.

}

public boolean isEnabled(
Expand Down
Loading