Skip to content

Commit 4ceae78

Browse files
committed
Merge remote-tracking branch 'origin/master' into typo/evaluator-type-mismatch
2 parents 215d07a + aa7c70f commit 4ceae78

File tree

212 files changed

+6383
-2475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+6383
-2475
lines changed

.github/workflows/run-system-tests.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ jobs:
6363
- build
6464
# If you change the following comment, update the pattern in the update_system_test_reference.sh script to match.
6565
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main # system tests are pinned on release branches only
66-
secrets:
67-
TEST_OPTIMIZATION_API_KEY: ${{ secrets.DATADOG_API_KEY_PROD }}
6866
permissions:
6967
contents: read
7068
id-token: write
@@ -78,7 +76,7 @@ jobs:
7876
scenarios_groups: tracer-release
7977
excluded_scenarios: APM_TRACING_E2E_OTEL,APM_TRACING_E2E_SINGLE_SPAN,PROFILING # exclude flaky scenarios
8078
skip_empty_scenarios: true
81-
push_to_test_optimization: true
79+
push_to_test_optimization: false # disabled to avoid pushing to Test Optimization while API key is transitioning to system-tests
8280

8381
# Ensure the main job is run to completion
8482
check:

.gitlab/benchmarks/bp-runner.fail-on-breach.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Generated: 2026-03-31
33
#
44
# Generation Strategy: tight
5-
# Formula: CI_bound / (1 ± T) (T = 5.0%)
5+
# Formula: CI_bound / (1 ± T) (T = 10.0%)
66
#
77
# SLO Checking:
88
# - BREACH: 90% CI boundary crosses threshold
@@ -11,7 +11,7 @@
1111
# DO NOT EDIT MANUALLY - Regenerate using:
1212
# benchmark_analyzer generate slos --help
1313
#
14-
# Thresholds set based on guidance in https://datadoghq.atlassian.net/wiki/x/LgI1LgE#How-to-choose-thresholds-for-pre-release-gates%3F
14+
# link to documentation on autogenerated thresholds https://github.com/DataDog/relenv-benchmark-analyzer/blob/main/README.md#generate-slo-thresholds
1515

1616
experiments:
1717
- name: Run SLO breach check
@@ -31,7 +31,7 @@ experiments:
3131
# https://benchmarking.us1.prod.dog/trends?projectId=4&branch=master&trendsTab=per_scenario&scenario=normal_operation%2Fonly-tracing&trendsType=scenario
3232
- name: normal_operation/only-tracing
3333
thresholds:
34-
- agg_http_req_duration_p50 < 2.128 ms
34+
- agg_http_req_duration_p50 < 2.526 ms
3535
- agg_http_req_duration_p99 < 8.5 ms
3636
# https://benchmarking.us1.prod.dog/trends?projectId=4&branch=master&trendsTab=per_scenario&scenario=normal_operation%2Fotel-latest&trendsType=scenario
3737
- name: normal_operation/otel-latest

.gitlab/one-pipeline.locked.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# DO NOT EDIT THIS FILE MANUALLY
22
# This file is auto-generated by automation.
33
include:
4-
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/9cf7d7609ff62e4723c9cbc061ca2a25345ce5d6055b9acad9a13dbf736261f0/one-pipeline.yml
4+
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/4667b01c6ae983f92ecf106e110ced3dac798b229cf2a0539c58aa22e95a99d5/one-pipeline.yml

buildSrc/src/main/kotlin/dd-trace-java.configure-tests.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ tasks.withType<Test>().configureEach {
4646
// Use a task-specific user prefs directory
4747
systemProperty("java.util.prefs.userRoot", layout.buildDirectory.dir("tmp/userPrefs/$name").get().asFile.absolutePath)
4848

49+
// Enable JUnit 5 auto-detection so ConfigInversionExtension (STRICT mode) is loaded automatically
50+
systemProperty("junit.jupiter.extensions.autodetection.enabled", "true")
51+
4952
// Split up tests that want to run forked in their own separate JVM for generated tasks
5053
if (name.startsWith("forkedTest") || name.endsWith("ForkedTest")) {
5154
setExcludes(emptyList())

communication/src/main/java/datadog/communication/http/OkHttpUtils.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.net.InetSocketAddress;
1616
import java.net.Proxy;
1717
import java.nio.ByteBuffer;
18+
import java.util.Arrays;
1819
import java.util.Collections;
1920
import java.util.List;
2021
import java.util.Map;
@@ -27,6 +28,7 @@
2728
import okhttp3.HttpUrl;
2829
import okhttp3.MediaType;
2930
import okhttp3.OkHttpClient;
31+
import okhttp3.Protocol;
3032
import okhttp3.Request;
3133
import okhttp3.RequestBody;
3234
import okhttp3.Response;
@@ -62,7 +64,7 @@ public static OkHttpClient buildHttpClient(final HttpUrl url, final long timeout
6264
}
6365

6466
public static OkHttpClient buildHttpClient(
65-
final boolean isHttp,
67+
final boolean isPlainHttp,
6668
final String unixDomainSocketPath,
6769
final String namedPipe,
6870
final long timeoutMillis) {
@@ -71,7 +73,30 @@ public static OkHttpClient buildHttpClient(
7173
Config.get().isJdkSocketEnabled(),
7274
namedPipe,
7375
null,
74-
isHttp,
76+
isPlainHttp,
77+
false,
78+
null,
79+
null,
80+
null,
81+
null,
82+
null,
83+
null,
84+
timeoutMillis,
85+
Config.get().isAgentConfiguredUsingDefault());
86+
}
87+
88+
public static OkHttpClient buildHttp2Client(
89+
final boolean isPlainHttp,
90+
final String unixDomainSocketPath,
91+
final String namedPipe,
92+
final long timeoutMillis) {
93+
return buildHttpClient(
94+
unixDomainSocketPath,
95+
Config.get().isJdkSocketEnabled(),
96+
namedPipe,
97+
null,
98+
isPlainHttp,
99+
true,
75100
null,
76101
null,
77102
null,
@@ -99,6 +124,7 @@ public static OkHttpClient buildHttpClient(
99124
config.getAgentNamedPipe(),
100125
dispatcher,
101126
isPlainHttp(url),
127+
false,
102128
retryOnConnectionFailure,
103129
maxRunningRequests,
104130
proxyHost,
@@ -116,7 +142,8 @@ private static OkHttpClient buildHttpClient(
116142
final boolean useJdkUnixDomainSocket,
117143
final String namedPipe,
118144
final Dispatcher dispatcher,
119-
final boolean isHttp,
145+
final boolean isPlainHttp,
146+
final boolean isHttp2,
120147
final Boolean retryOnConnectionFailure,
121148
final Integer maxRunningRequests,
122149
final String proxyHost,
@@ -159,11 +186,19 @@ private static OkHttpClient buildHttpClient(
159186
log.debug("Using NamedPipe as http transport");
160187
}
161188

162-
if (isHttp) {
189+
if (isPlainHttp) {
163190
// force clear text when using http to avoid failures for JVMs without TLS
164191
builder.connectionSpecs(Collections.singletonList(ConnectionSpec.CLEARTEXT));
165192
}
166193

194+
if (isHttp2) {
195+
if (isPlainHttp) {
196+
builder.protocols(Collections.singletonList(Protocol.H2_PRIOR_KNOWLEDGE));
197+
} else {
198+
builder.protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1));
199+
}
200+
}
201+
167202
if (retryOnConnectionFailure != null) {
168203
builder.retryOnConnectionFailure(retryOnConnectionFailure);
169204
}

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/AsyncResultDecorator.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@
1111
*/
1212
public abstract class AsyncResultDecorator extends BaseDecorator {
1313

14-
private static final ClassValue<AsyncResultExtension> EXTENSION_CLASS_VALUE =
15-
new ClassValue<AsyncResultExtension>() {
16-
@Override
17-
protected AsyncResultExtension computeValue(Class<?> type) {
18-
return AsyncResultExtensions.registered().stream()
19-
.filter(extension -> extension.supports(type))
20-
.findFirst()
21-
.orElse(null);
22-
}
23-
};
24-
2514
/**
2615
* Look for asynchronous result and decorate it with span finisher. If the result is not
2716
* asynchronous, it will be return unmodified and span will be finished.
@@ -33,12 +22,9 @@ protected AsyncResultExtension computeValue(Class<?> type) {
3322
*/
3423
public Object wrapAsyncResultOrFinishSpan(
3524
final Object result, final Class<?> methodReturnType, final AgentSpan span) {
36-
AsyncResultExtension extension;
37-
if (result != null && (extension = EXTENSION_CLASS_VALUE.get(methodReturnType)) != null) {
38-
Object applied = extension.apply(result, span);
39-
if (applied != null) {
40-
return applied;
41-
}
25+
Object applied = AsyncResultExtensions.wrapAsyncResult(result, methodReturnType, span);
26+
if (applied != null) {
27+
return applied;
4228
}
4329
// If no extension was applied, immediately finish the span and return the original result
4430
span.finish();

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtensions.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ public final class AsyncResultExtensions {
1616
private static final List<AsyncResultExtension> EXTENSIONS =
1717
new CopyOnWriteArrayList<>(singletonList(new CompletableAsyncResultExtension()));
1818

19+
private static final ClassValue<AsyncResultExtension> EXTENSION_CLASS_VALUE =
20+
new ClassValue<AsyncResultExtension>() {
21+
@Override
22+
protected AsyncResultExtension computeValue(Class<?> type) {
23+
return EXTENSIONS.stream()
24+
.filter(extension -> extension.supports(type))
25+
.findFirst()
26+
.orElse(null);
27+
}
28+
};
29+
30+
/**
31+
* Wraps a supported async result so the span is finished when the async computation completes.
32+
*
33+
* @return the wrapped async result, or {@code null} if the result type is unsupported or no
34+
* wrapping is applied
35+
*/
36+
public static Object wrapAsyncResult(
37+
final Object result, final Class<?> resultType, final AgentSpan span) {
38+
AsyncResultExtension extension;
39+
if (result != null && (extension = EXTENSION_CLASS_VALUE.get(resultType)) != null) {
40+
return extension.apply(result, span);
41+
}
42+
return null;
43+
}
44+
1945
/**
2046
* Registers an extension to add supported async types.
2147
*
@@ -36,11 +62,6 @@ public static void register(AsyncResultExtension extension) {
3662
}
3763
}
3864

39-
/** Returns the list of currently registered extensions. */
40-
public static List<AsyncResultExtension> registered() {
41-
return EXTENSIONS;
42-
}
43-
4465
static final class CompletableAsyncResultExtension implements AsyncResultExtension {
4566
@Override
4667
public boolean supports(Class<?> result) {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package datadog.trace.bootstrap.instrumentation.java.lang;
22

3+
/** This class is a helper for the java-lang-21.0 {@code VirtualThreadInstrumentation}. */
34
public final class VirtualThreadHelper {
45
public static final String VIRTUAL_THREAD_CLASS_NAME = "java.lang.VirtualThread";
56

67
/**
7-
* {@link datadog.trace.bootstrap.instrumentation.api.AgentScope} class name as string literal.
8-
* This is mandatory for {@link datadog.trace.bootstrap.ContextStore} API call.
8+
* {@link VirtualThreadState} class name as string literal. This is mandatory for {@link
9+
* datadog.trace.bootstrap.ContextStore} API call.
910
*/
10-
public static final String AGENT_SCOPE_CLASS_NAME =
11-
"datadog.trace.bootstrap.instrumentation.api.AgentScope";
11+
public static final String VIRTUAL_THREAD_STATE_CLASS_NAME =
12+
"datadog.trace.bootstrap.instrumentation.java.lang.VirtualThreadState";
1213
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package datadog.trace.bootstrap.instrumentation.java.lang;
2+
3+
import datadog.context.Context;
4+
import datadog.trace.bootstrap.instrumentation.api.AgentScope.Continuation;
5+
6+
/**
7+
* This class holds the saved context and scope continuation for a virtual thread.
8+
*
9+
* <p>Used by java-lang-21.0 {@code VirtualThreadInstrumentation} to swap the entire scope stack on
10+
* mount/unmount.
11+
*/
12+
public final class VirtualThreadState {
13+
/** The virtual thread's saved context (scope stack snapshot). */
14+
private Context context;
15+
16+
/** Prevents the enclosing context scope from completing before the virtual thread finishes. */
17+
private final Continuation continuation;
18+
19+
/** The carrier thread's saved context, set between mount and unmount. */
20+
private Context previousContext;
21+
22+
public VirtualThreadState(Context context, Continuation continuation) {
23+
this.context = context;
24+
this.continuation = continuation;
25+
}
26+
27+
/** Called on mount: swaps the virtual thread's context into the carrier thread. */
28+
public void onMount() {
29+
this.previousContext = this.context.swap();
30+
}
31+
32+
/** Called on unmount: restores the carrier thread's original context. */
33+
public void onUnmount() {
34+
if (this.previousContext != null) {
35+
this.context = this.previousContext.swap();
36+
this.previousContext = null;
37+
}
38+
}
39+
40+
/** Called on termination: releases the trace continuation. */
41+
public void onTerminate() {
42+
if (this.continuation != null) {
43+
this.continuation.cancel();
44+
}
45+
}
46+
}

dd-java-agent/agent-ci-visibility/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies {
3737
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
3838
testImplementation group: 'org.freemarker', name: 'freemarker', version: '2.3.31'
3939
testImplementation group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.6'
40+
testImplementation libs.bundles.mockito
4041
}
4142

4243
tasks.named("shadowJar", ShadowJar) {

0 commit comments

Comments
 (0)