Skip to content

Commit fdcaad3

Browse files
Merge branch 'master' into daniel.mohedano/maven-smoke-feedback
2 parents e633223 + 847275b commit fdcaad3

File tree

405 files changed

+10807
-1614
lines changed

Some content is hidden

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

405 files changed

+10807
-1614
lines changed

.gitlab-ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ variables:
2525
BUILD_JOB_NAME: "build"
2626
DEPENDENCY_CACHE_POLICY: pull
2727
BUILD_CACHE_POLICY: pull
28-
GRADLE_VERSION: "8.5" # must match gradle-wrapper.properties
28+
GRADLE_VERSION: "8.14.3" # must match gradle-wrapper.properties
2929
MAVEN_REPOSITORY_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/maven-central/"
3030
GRADLE_PLUGIN_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/gradle-plugin-portal-proxy/"
31-
BUILDER_IMAGE_VERSION_PREFIX: "v25.06-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
31+
BUILDER_IMAGE_VERSION_PREFIX: "v25.07-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
3232
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
3333
DEFAULT_TEST_JVMS: /^(8|11|17|21|stable)$/
3434
PROFILE_TESTS:
@@ -137,9 +137,12 @@ default:
137137
KUBERNETES_MEMORY_REQUEST: 8Gi
138138
KUBERNETES_MEMORY_LIMIT: 8Gi
139139
CACHE_TYPE: lib #default
140+
FF_USE_FASTZIP: "true"
141+
CACHE_COMPRESSION_LEVEL: "slowest"
142+
140143
RUNTIME_AVAILABLE_PROCESSORS_OVERRIDE: 4 # Runtime.getRuntime().availableProcessors() returns incorrect or very high values in Kubernetes
141144
cache:
142-
- key: '$CI_SERVER_VERSION-$CACHE_TYPE' # Dependencies cache. Reset the cache every time gitlab is upgraded. ~Every couple months
145+
- key: dependency-$CACHE_TYPE # Dependencies cache
143146
paths:
144147
# Cached dependencies and wrappers for gradle
145148
- .gradle/wrapper
@@ -148,8 +151,8 @@ default:
148151
policy: $DEPENDENCY_CACHE_POLICY
149152
unprotect: true
150153
fallback_keys: # Use fallback keys because all cache types are not populated. See note under: populate_dep_cache
151-
- '$CI_SERVER_VERSION-base'
152-
- '$CI_SERVER_VERSION-lib'
154+
- 'dependency-base'
155+
- 'dependency-lib'
153156
- key: $CI_PIPELINE_ID-$CACHE_TYPE # Incremental build cache. Shared by all jobs in the pipeline of the same type
154157
paths:
155158
- .gradle/caches/$GRADLE_VERSION
@@ -837,7 +840,7 @@ package-oci:
837840

838841
configure_system_tests:
839842
variables:
840-
SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,docker-ssi,lib-injection"
843+
SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,simple_onboarding_appsec,docker-ssi,lib-injection"
841844

842845
create_key:
843846
stage: generate-signing-key

.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/d44e89797a5a47c43cf712193abefe2178a004176606f7e01b77d1ec49a3ef5e/one-pipeline.yml
4+
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/a0486057161f85a77e39ad2aa60ac66bb52414696d9b3dd87177df1057b11295/one-pipeline.yml

.gitlab/upload_ciapp.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,20 @@ junit_upload() {
3535
./results
3636
}
3737

38+
# Upload code coverage results to Datadog
39+
coverage_upload() {
40+
DD_API_KEY=$1 \
41+
[email protected]:DataDog/dd-trace-java.git \
42+
datadog-ci coverage upload --ignored-paths=./test-published-dependencies .
43+
}
44+
3845
# Upload test results to production environment like all other CI jobs
3946
junit_upload "$DATADOG_API_KEY_PROD"
47+
junit_upload_status=$?
48+
49+
coverage_upload "$DATADOG_API_KEY_PROD"
50+
coverage_upload_status=$?
51+
52+
if [[ $junit_upload_status -ne 0 || $coverage_upload_status -ne 0 ]]; then
53+
exit 1
54+
fi

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies {
4646
implementation("org.ow2.asm", "asm", "9.8")
4747
implementation("org.ow2.asm", "asm-tree", "9.8")
4848

49-
testImplementation("org.spockframework", "spock-core", "2.2-groovy-3.0")
49+
testImplementation(libs.spock.core)
5050
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")
5151
}
5252

buildSrc/call-site-instrumentation-plugin/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
3838

3939
testImplementation("net.bytebuddy", "byte-buddy", "1.17.5")
40-
testImplementation("org.spockframework", "spock-core", "2.0-groovy-3.0")
40+
testImplementation(libs.spock.core)
4141
testImplementation("org.objenesis", "objenesis", "3.0.1")
4242
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")
4343
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
@@ -68,7 +68,7 @@ val copyCallSiteSources = tasks.register<Copy>("copyCallSiteSources") {
6868
}
6969

7070
tasks {
71-
withType<AbstractCompile>() {
71+
withType<AbstractCompile> {
7272
dependsOn(copyCallSiteSources)
7373
}
7474
}

buildSrc/settings.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
include(":call-site-instrumentation-plugin")
2+
3+
dependencyResolutionManagement {
4+
versionCatalogs {
5+
create("libs") {
6+
from(files("../gradle/libs.versions.toml"))
7+
}
8+
}
9+
}

communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package datadog.communication.ddagent;
22

3+
import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_ID;
4+
import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_TAGS_HASH;
35
import static datadog.communication.serialization.msgpack.MsgPackWriter.FIXARRAY;
6+
import static java.util.Collections.emptySet;
47
import static java.util.Collections.singletonList;
8+
import static java.util.Collections.unmodifiableSet;
59

610
import com.squareup.moshi.JsonAdapter;
711
import com.squareup.moshi.Moshi;
812
import com.squareup.moshi.Types;
13+
import datadog.common.container.ContainerInfo;
914
import datadog.communication.http.OkHttpUtils;
1015
import datadog.communication.monitor.DDAgentStatsDClientManager;
1116
import datadog.communication.monitor.Monitoring;
@@ -86,6 +91,8 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
8691
private volatile String evpProxyEndpoint;
8792
private volatile String version;
8893
private volatile String telemetryProxyEndpoint;
94+
private volatile Set<String> peerTags = emptySet();
95+
private volatile Set<String> spanKindsToComputedStats = emptySet();
8996

9097
private long lastTimeDiscovered;
9198

@@ -119,6 +126,8 @@ private void reset() {
119126
version = null;
120127
lastTimeDiscovered = 0;
121128
telemetryProxyEndpoint = null;
129+
peerTags = emptySet();
130+
spanKindsToComputedStats = emptySet();
122131
}
123132

124133
/** Run feature discovery, unconditionally. */
@@ -151,11 +160,15 @@ private void doDiscovery() {
151160
// 3. fallback if the endpoint couldn't be found or the response couldn't be parsed
152161
try (Recording recording = discoveryTimer.start()) {
153162
boolean fallback = true;
154-
try (Response response =
155-
client
156-
.newCall(new Request.Builder().url(agentBaseUrl.resolve("info").url()).build())
157-
.execute()) {
163+
final Request.Builder requestBuilder =
164+
new Request.Builder().url(agentBaseUrl.resolve("info").url());
165+
final String containerId = ContainerInfo.get().getContainerId();
166+
if (containerId != null) {
167+
requestBuilder.header(DATADOG_CONTAINER_ID, containerId);
168+
}
169+
try (Response response = client.newCall(requestBuilder.build()).execute()) {
158170
if (response.isSuccessful()) {
171+
processInfoResponseHeaders(response);
159172
fallback = !processInfoResponse(response.body().string());
160173
}
161174
} catch (Throwable error) {
@@ -216,6 +229,10 @@ private String probeTracesEndpoint(String[] endpoints) {
216229
return V3_ENDPOINT;
217230
}
218231

232+
private void processInfoResponseHeaders(Response response) {
233+
ContainerInfo.get().setContainerTagsHash(response.header(DATADOG_CONTAINER_TAGS_HASH));
234+
}
235+
219236
@SuppressWarnings("unchecked")
220237
private boolean processInfoResponse(String response) {
221238
try {
@@ -287,6 +304,18 @@ private boolean processInfoResponse(String response) {
287304
null != canDrop
288305
&& ("true".equalsIgnoreCase(String.valueOf(canDrop))
289306
|| Boolean.TRUE.equals(canDrop));
307+
308+
Object peer_tags = map.get("peer_tags");
309+
peerTags =
310+
peer_tags instanceof List
311+
? unmodifiableSet(new HashSet<>((List<String>) peer_tags))
312+
: emptySet();
313+
314+
Object span_kinds = map.get("span_kinds_stats_computed");
315+
spanKindsToComputedStats =
316+
span_kinds instanceof List
317+
? unmodifiableSet(new HashSet<>((List<String>) span_kinds))
318+
: emptySet();
290319
}
291320
try {
292321
state = Strings.sha256(response);
@@ -344,6 +373,14 @@ public boolean supportsLongRunning() {
344373
return supportsLongRunning;
345374
}
346375

376+
public Set<String> peerTags() {
377+
return peerTags;
378+
}
379+
380+
public Set<String> spanKindsToComputedStats() {
381+
return spanKindsToComputedStats;
382+
}
383+
347384
public String getMetricsEndpoint() {
348385
return metricsEndpoint;
349386
}

communication/src/main/java/datadog/communication/ddagent/SharedCommunicationObjects.java

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class SharedCommunicationObjects {
3030
public OkHttpClient okHttpClient;
3131
public HttpUrl agentUrl;
3232
public Monitoring monitoring;
33-
private DDAgentFeaturesDiscovery featuresDiscovery;
33+
private volatile DDAgentFeaturesDiscovery featuresDiscovery;
3434
private ConfigurationPoller configurationPoller;
3535

3636
public SharedCommunicationObjects() {
@@ -139,28 +139,34 @@ public void setFeaturesDiscovery(DDAgentFeaturesDiscovery featuresDiscovery) {
139139
}
140140

141141
public DDAgentFeaturesDiscovery featuresDiscovery(Config config) {
142-
if (featuresDiscovery == null) {
143-
createRemaining(config);
144-
featuresDiscovery =
145-
new DDAgentFeaturesDiscovery(
146-
okHttpClient,
147-
monitoring,
148-
agentUrl,
149-
config.isTraceAgentV05Enabled(),
150-
config.isTracerMetricsEnabled());
151-
152-
if (paused) {
153-
// defer remote discovery until remote I/O is allowed
154-
} else {
155-
if (AGENT_THREAD_GROUP.equals(Thread.currentThread().getThreadGroup())) {
156-
featuresDiscovery.discover(); // safe to run on same thread
157-
} else {
158-
// avoid performing blocking I/O operation on application thread
159-
AgentTaskScheduler.INSTANCE.execute(featuresDiscovery::discover);
142+
DDAgentFeaturesDiscovery ret = featuresDiscovery;
143+
if (ret == null) {
144+
synchronized (this) {
145+
if (featuresDiscovery == null) {
146+
createRemaining(config);
147+
ret =
148+
new DDAgentFeaturesDiscovery(
149+
okHttpClient,
150+
monitoring,
151+
agentUrl,
152+
config.isTraceAgentV05Enabled(),
153+
config.isTracerMetricsEnabled());
154+
155+
if (paused) {
156+
// defer remote discovery until remote I/O is allowed
157+
} else {
158+
if (AGENT_THREAD_GROUP.equals(Thread.currentThread().getThreadGroup())) {
159+
ret.discover(); // safe to run on same thread
160+
} else {
161+
// avoid performing blocking I/O operation on application thread
162+
AgentTaskScheduler.INSTANCE.execute(ret::discoverIfOutdated);
163+
}
164+
}
165+
featuresDiscovery = ret;
160166
}
161167
}
162168
}
163-
return featuresDiscovery;
169+
return ret;
164170
}
165171

166172
private static final class FixedConfigUrlSupplier implements Supplier<String> {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public final class OkHttpUtils {
4343
private static final String DATADOG_META_LANG_INTERPRETER = "Datadog-Meta-Lang-Interpreter";
4444
private static final String DATADOG_META_LANG_INTERPRETER_VENDOR =
4545
"Datadog-Meta-Lang-Interpreter-Vendor";
46-
private static final String DATADOG_CONTAINER_ID = "Datadog-Container-ID";
46+
public static final String DATADOG_CONTAINER_ID = "Datadog-Container-ID";
4747
private static final String DATADOG_ENTITY_ID = "Datadog-Entity-ID";
48+
public static final String DATADOG_CONTAINER_TAGS_HASH = "Datadog-Container-Tags-Hash";
4849

4950
private static final String DD_API_KEY = "DD-API-KEY";
5051

communication/src/test/groovy/datadog/communication/ddagent/DDAgentFeaturesDiscoveryTest.groovy

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package datadog.communication.ddagent
22

3+
import datadog.common.container.ContainerInfo
34
import datadog.communication.monitor.Monitoring
45
import datadog.trace.test.util.DDSpecification
56
import datadog.trace.util.Strings
67
import okhttp3.Call
8+
import okhttp3.Headers
79
import okhttp3.HttpUrl
810
import okhttp3.MediaType
911
import okhttp3.OkHttpClient
@@ -19,6 +21,8 @@ import java.nio.file.Paths
1921
import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V01_DATASTREAMS_ENDPOINT
2022
import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V6_METRICS_ENDPOINT
2123
import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V7_CONFIG_ENDPOINT
24+
import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_ID
25+
import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_TAGS_HASH
2226

2327
class DDAgentFeaturesDiscoveryTest extends DDSpecification {
2428

@@ -30,6 +34,8 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
3034

3135
static final String INFO_RESPONSE = loadJsonFile("agent-info.json")
3236
static final String INFO_STATE = Strings.sha256(INFO_RESPONSE)
37+
static final String INFO_WITH_PEER_TAG_BACK_PROPAGATION_RESPONSE = loadJsonFile("agent-info-with-peer-tag-back-propagation.json")
38+
static final String INFO_WITH_PEER_TAG_BACK_PROPAGATION_STATE = Strings.sha256(INFO_WITH_PEER_TAG_BACK_PROPAGATION_RESPONSE)
3339
static final String INFO_WITH_CLIENT_DROPPING_RESPONSE = loadJsonFile("agent-info-with-client-dropping.json")
3440
static final String INFO_WITH_CLIENT_DROPPING_STATE = Strings.sha256(INFO_WITH_CLIENT_DROPPING_RESPONSE)
3541
static final String INFO_WITHOUT_METRICS_RESPONSE = loadJsonFile("agent-info-without-metrics.json")
@@ -424,13 +430,77 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
424430
!features.supportsContentEncodingHeadersWithEvpProxy()
425431
}
426432

427-
def infoResponse(Request request, String json) {
433+
def "test parse /info response with peer tag back propagation"() {
434+
setup:
435+
OkHttpClient client = Mock(OkHttpClient)
436+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
437+
438+
when: "/info available"
439+
features.discover()
440+
441+
then:
442+
1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_RESPONSE) }
443+
444+
when: "/info available with peer tag back propagation"
445+
features.discover()
446+
447+
then:
448+
1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_WITH_PEER_TAG_BACK_PROPAGATION_RESPONSE) }
449+
features.state() == INFO_WITH_PEER_TAG_BACK_PROPAGATION_STATE
450+
features.supportsDropping()
451+
features.peerTags().containsAll(
452+
"_dd.base_service",
453+
"active_record.db.vendor",
454+
"amqp.destination",
455+
"amqp.exchange",
456+
"amqp.queue",
457+
"grpc.host",
458+
"hostname",
459+
"http.host",
460+
"http.server_name",
461+
"streamname",
462+
"tablename",
463+
"topicname"
464+
)
465+
features.spanKindsToComputedStats().containsAll(
466+
"client",
467+
"consumer",
468+
"producer",
469+
"server"
470+
)
471+
}
472+
473+
def "should send container id as header on the info request and parse the hash in the response"() {
474+
setup:
475+
OkHttpClient client = Mock(OkHttpClient)
476+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
477+
def oldContainerId = ContainerInfo.get().getContainerId()
478+
def oldContainerTagsHash = ContainerInfo.get().getContainerTagsHash()
479+
ContainerInfo.get().setContainerId("test")
480+
481+
when: "/info requested"
482+
features.discover()
483+
484+
then:
485+
1 * client.newCall(_) >> { Request request ->
486+
assert request.header(DATADOG_CONTAINER_ID) == "test"
487+
infoResponse(request, INFO_RESPONSE, Headers.of(DATADOG_CONTAINER_TAGS_HASH, "test-hash"))
488+
}
489+
and:
490+
assert ContainerInfo.get().getContainerTagsHash() == "test-hash"
491+
cleanup:
492+
ContainerInfo.get().setContainerId(oldContainerId)
493+
ContainerInfo.get().setContainerTagsHash(oldContainerTagsHash)
494+
}
495+
496+
def infoResponse(Request request, String json, Headers headers = new Headers.Builder().build()) {
428497
return Mock(Call) {
429498
it.execute() >> new Response.Builder()
430499
.code(200)
431500
.request(request)
432501
.protocol(Protocol.HTTP_1_1)
433502
.message("")
503+
.headers(headers)
434504
.body(ResponseBody.create(MediaType.get("application/json"), json))
435505
.build()
436506
}

0 commit comments

Comments
 (0)