Skip to content

Commit 054841c

Browse files
committed
Enable by default
1 parent b89fe3c commit 054841c

7 files changed

Lines changed: 31 additions & 19 deletions

File tree

dd-java-agent/benchmark/src/jmh/java/lambdabench/LambdaExecutorBenchmark.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import org.openjdk.jmh.annotations.TearDown;
2020

2121
/**
22-
* Compares lambda {@code Runnable} allocation and submission with no agent, wrapping, and field
23-
* injection.
22+
* Compares lambda {@code Runnable} allocation, execution, and submission with no agent, wrapping,
23+
* and field injection.
2424
*
2525
* <ul>
2626
* <li>{@link NoAgent} — baseline, no agent.
@@ -30,8 +30,9 @@
3030
* field-injected, so no wrapper is allocated and identity is preserved.
3131
* </ul>
3232
*
33-
* <p>With the GC profiler, {@code allocateCapturingRunnable} isolates the injected field's object
34-
* size cost while {@code submitLambda} includes the wrapper allocation tradeoff. Run with:
33+
* <p>{@code runUntracedLambda} isolates the advice cost when no context was attached. With the GC
34+
* profiler, {@code allocateCapturingRunnable} isolates the injected field's object size cost while
35+
* {@code submitLambda} includes the wrapper allocation tradeoff. Run with:
3536
*
3637
* <pre>{@code
3738
* ./gradlew :dd-java-agent:benchmark:jmh \
@@ -82,12 +83,30 @@ public static class CapturingLambdaState {
8283
public void run() {}
8384
}
8485

86+
@State(Scope.Thread)
87+
public static class DirectRunState {
88+
Runnable runnable;
89+
int executions;
90+
91+
@Setup
92+
public void setup() {
93+
runnable = () -> executions++;
94+
}
95+
}
96+
8597
/** Allocates an untraced capturing Runnable. */
8698
@Benchmark
8799
public Runnable allocateCapturingRunnable(CapturingLambdaState state) {
88100
return state::run;
89101
}
90102

103+
/** Executes an already-created lambda Runnable without an active trace. */
104+
@Benchmark
105+
public int runUntracedLambda(DirectRunState state) {
106+
state.runnable.run();
107+
return state.executions;
108+
}
109+
91110
/** Submit a lambda Runnable to the executor under an active trace, and wait for it to run. */
92111
@Benchmark
93112
public void submitLambda(ExecutorState state) throws InterruptedException {
@@ -134,9 +153,9 @@ private static Object supplyTarget() {
134153
@Fork
135154
public static class NoAgent extends LambdaExecutorBenchmark {}
136155

137-
@Fork(jvmArgsAppend = AGENT)
156+
@Fork(jvmArgsAppend = {AGENT, "-Ddd.trace.lambda.enabled=false"})
138157
public static class AgentLambdaOff extends LambdaExecutorBenchmark {}
139158

140-
@Fork(jvmArgsAppend = {AGENT, "-Ddd.trace.lambda.enabled=true"})
159+
@Fork(jvmArgsAppend = AGENT)
141160
public static class AgentLambdaOn extends LambdaExecutorBenchmark {}
142161
}

dd-java-agent/instrumentation/java/java-lambda/java-lambda-1.8/src/main/java/datadog/trace/instrumentation/java/lang/invoke/LambdaMetafactoryInstrumentation.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ public LambdaMetafactoryInstrumentation() {
5252
super("lambda");
5353
}
5454

55-
@Override
56-
protected boolean defaultEnabled() {
57-
return false;
58-
}
59-
6055
@Override
6156
public String instrumentedType() {
6257
return METAFACTORY;

dd-java-agent/instrumentation/java/java-lambda/java-lambda-1.8/src/test/java/testdog/trace/instrumentation/lambda/ClojureAFnIntegrationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import datadog.trace.test.junit.utils.config.WithConfig;
1111
import org.junit.jupiter.api.Test;
1212

13-
@WithConfig(key = "trace.lambda.enabled", value = "true")
1413
@WithConfig(key = "trace.runnable.enabled", value = "false")
1514
public class ClojureAFnIntegrationTest extends AbstractInstrumentationTest {
1615

dd-java-agent/instrumentation/java/java-lambda/java-lambda-1.8/src/test/java/testdog/trace/instrumentation/lambda/LambdaMetafactoryIntegrationTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import datadog.trace.api.Trace;
1313
import datadog.trace.bootstrap.FieldBackedContextAccessor;
1414
import datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper;
15-
import datadog.trace.test.junit.utils.config.WithConfig;
1615
import java.util.concurrent.CountDownLatch;
1716
import java.util.concurrent.ExecutorService;
1817
import java.util.concurrent.Executors;
@@ -22,7 +21,6 @@
2221
import org.junit.jupiter.api.Test;
2322

2423
/** Lambda integration tests outside the ignored {@code datadog.*} prefix. */
25-
@WithConfig(key = "trace.lambda.enabled", value = "true")
2624
public class LambdaMetafactoryIntegrationTest extends AbstractInstrumentationTest {
2725

2826
@Test

dd-smoke-tests/java9-modules/src/main/java11/testdog/moduleapp/LambdaTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public static void runOnExecutor() throws InterruptedException {
1919
try {
2020
final CountDownLatch latch = new CountDownLatch(1);
2121
final Runnable task = latch::countDown;
22-
assertFieldInjection(task, Boolean.getBoolean("dd.trace.lambda.enabled"));
22+
assertFieldInjection(
23+
task, Boolean.parseBoolean(System.getProperty("dd.trace.lambda.enabled", "true")));
2324
pool.execute(task);
2425
if (!latch.await(10, TimeUnit.SECONDS)) {
2526
throw new IllegalStateException("lambda task did not run");

dd-smoke-tests/java9-modules/src/test/groovy/datadog/smoketest/Java9ModulesLambdaSmokeTest.groovy renamed to dd-smoke-tests/java9-modules/src/test/groovy/datadog/smoketest/Java9ModulesLambdaDisabledSmokeTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import datadog.environment.JavaVirtualMachine
44
import datadog.environment.OperatingSystem
55
import spock.lang.IgnoreIf
66

7-
/** Verifies field injection adds the required read edge to a named module. */
7+
/** Verifies lambda transformation can be disabled for a named module. */
88
@IgnoreIf({
99
OperatingSystem.isLinux() && OperatingSystem.architecture().isArm64() && JavaVirtualMachine.isJ9()
1010
})
11-
class Java9ModulesLambdaSmokeTest extends Java9ModulesSmokeTest {
11+
class Java9ModulesLambdaDisabledSmokeTest extends Java9ModulesSmokeTest {
1212
@Override
1313
def javaProperties() {
14-
return super.javaProperties() + "-Ddd.trace.lambda.enabled=true"
14+
return super.javaProperties() + "-Ddd.trace.lambda.enabled=false"
1515
}
1616
}

metadata/supported-configurations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7957,7 +7957,7 @@
79577957
{
79587958
"version": "A",
79597959
"type": "boolean",
7960-
"default": "false",
7960+
"default": "true",
79617961
"aliases": ["DD_TRACE_INTEGRATION_LAMBDA_ENABLED", "DD_INTEGRATION_LAMBDA_ENABLED"]
79627962
}
79637963
],

0 commit comments

Comments
 (0)