Skip to content

Commit 0708dfb

Browse files
committed
Merge remote-tracking branch 'origin/master' into bdu/r-gate
2 parents 616ae97 + 847275b commit 0708dfb

File tree

320 files changed

+9285
-1305
lines changed

Some content is hidden

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

320 files changed

+9285
-1305
lines changed

.gitlab-ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

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.3-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: 1 addition & 1 deletion
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.3-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")

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: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +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;
4-
import static java.util.Collections.emptyList;
6+
import static java.util.Collections.emptySet;
57
import static java.util.Collections.singletonList;
6-
import static java.util.Collections.unmodifiableList;
8+
import static java.util.Collections.unmodifiableSet;
79

810
import com.squareup.moshi.JsonAdapter;
911
import com.squareup.moshi.Moshi;
1012
import com.squareup.moshi.Types;
13+
import datadog.common.container.ContainerInfo;
1114
import datadog.communication.http.OkHttpUtils;
1215
import datadog.communication.monitor.DDAgentStatsDClientManager;
1316
import datadog.communication.monitor.Monitoring;
@@ -88,8 +91,8 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
8891
private volatile String evpProxyEndpoint;
8992
private volatile String version;
9093
private volatile String telemetryProxyEndpoint;
91-
private volatile List<String> peerTags = emptyList();
92-
private volatile List<String> spanKindsToComputedStats = emptyList();
94+
private volatile Set<String> peerTags = emptySet();
95+
private volatile Set<String> spanKindsToComputedStats = emptySet();
9396

9497
private long lastTimeDiscovered;
9598

@@ -123,8 +126,8 @@ private void reset() {
123126
version = null;
124127
lastTimeDiscovered = 0;
125128
telemetryProxyEndpoint = null;
126-
peerTags = emptyList();
127-
spanKindsToComputedStats = emptyList();
129+
peerTags = emptySet();
130+
spanKindsToComputedStats = emptySet();
128131
}
129132

130133
/** Run feature discovery, unconditionally. */
@@ -157,11 +160,15 @@ private void doDiscovery() {
157160
// 3. fallback if the endpoint couldn't be found or the response couldn't be parsed
158161
try (Recording recording = discoveryTimer.start()) {
159162
boolean fallback = true;
160-
try (Response response =
161-
client
162-
.newCall(new Request.Builder().url(agentBaseUrl.resolve("info").url()).build())
163-
.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()) {
164170
if (response.isSuccessful()) {
171+
processInfoResponseHeaders(response);
165172
fallback = !processInfoResponse(response.body().string());
166173
}
167174
} catch (Throwable error) {
@@ -222,6 +229,10 @@ private String probeTracesEndpoint(String[] endpoints) {
222229
return V3_ENDPOINT;
223230
}
224231

232+
private void processInfoResponseHeaders(Response response) {
233+
ContainerInfo.get().setContainerTagsHash(response.header(DATADOG_CONTAINER_TAGS_HASH));
234+
}
235+
225236
@SuppressWarnings("unchecked")
226237
private boolean processInfoResponse(String response) {
227238
try {
@@ -295,11 +306,16 @@ private boolean processInfoResponse(String response) {
295306
|| Boolean.TRUE.equals(canDrop));
296307

297308
Object peer_tags = map.get("peer_tags");
298-
peerTags = peer_tags == null ? emptyList() : unmodifiableList((List<String>) peer_tags);
309+
peerTags =
310+
peer_tags instanceof List
311+
? unmodifiableSet(new HashSet<>((List<String>) peer_tags))
312+
: emptySet();
299313

300314
Object span_kinds = map.get("span_kinds_stats_computed");
301315
spanKindsToComputedStats =
302-
span_kinds == null ? emptyList() : unmodifiableList((List<String>) span_kinds);
316+
span_kinds instanceof List
317+
? unmodifiableSet(new HashSet<>((List<String>) span_kinds))
318+
: emptySet();
303319
}
304320
try {
305321
state = Strings.sha256(response);
@@ -357,11 +373,11 @@ public boolean supportsLongRunning() {
357373
return supportsLongRunning;
358374
}
359375

360-
public List<String> peerTags() {
376+
public Set<String> peerTags() {
361377
return peerTags;
362378
}
363379

364-
public List<String> spanKindsToComputedStats() {
380+
public Set<String> spanKindsToComputedStats() {
365381
return spanKindsToComputedStats;
366382
}
367383

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public DDAgentFeaturesDiscovery featuresDiscovery(Config config) {
159159
ret.discover(); // safe to run on same thread
160160
} else {
161161
// avoid performing blocking I/O operation on application thread
162-
AgentTaskScheduler.INSTANCE.execute(ret::discover);
162+
AgentTaskScheduler.INSTANCE.execute(ret::discoverIfOutdated);
163163
}
164164
}
165165
featuresDiscovery = ret;

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: 29 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

@@ -466,13 +470,37 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
466470
)
467471
}
468472

469-
def infoResponse(Request request, String json) {
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()) {
470497
return Mock(Call) {
471498
it.execute() >> new Response.Builder()
472499
.code(200)
473500
.request(request)
474501
.protocol(Protocol.HTTP_1_1)
475502
.message("")
503+
.headers(headers)
476504
.body(ResponseBody.create(MediaType.get("application/json"), json))
477505
.build()
478506
}

0 commit comments

Comments
 (0)