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
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ test_debugger_arm64:
- !reference [.test_job_arm64, script]

test_smoke:
extends: .test_job
extends: .test_job_with_test_agent
# needs:parallel:matrix limits this job to a specific build_tests combination.
# Keep matrix vars exact and in build_tests declaration order:
# https://docs.gitlab.com/ci/yaml/#needsparallelmatrix
Expand All @@ -1135,7 +1135,7 @@ test_smoke:
matrix: *test_matrix_8

test_smoke_arm64:
extends: .test_job_arm64
extends: .test_job_arm64_with_test_agent
variables:
<<: *tier_l_variables
GRADLE_TARGET: "stageMainDist :smokeTest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
public class SharedCommunicationObjects {
private static final Logger log = LoggerFactory.getLogger(SharedCommunicationObjects.class);

private static final String X_DATADOG_TEST_SESSION_TOKEN = "X-Datadog-Test-Session-Token";

private final List<Runnable> pausedComponents = new ArrayList<>();
private volatile boolean paused;

Expand Down Expand Up @@ -90,9 +92,27 @@ public void createRemaining(Config config) {
agentHttpClient =
OkHttpUtils.buildHttpClient(
OkHttpUtils.isPlainHttp(agentUrl), unixDomainSocket, namedPipe, httpClientTimeout);
String testSessionToken = config.getTestAgentSessionToken();
if (testSessionToken != null) {
agentHttpClient = injectTestAgentSessionHeaderInterceptor(testSessionToken);
}
}
}

private OkHttpClient injectTestAgentSessionHeaderInterceptor(String testSessionToken) {
return agentHttpClient
.newBuilder()
.addInterceptor(
chain ->
chain.proceed(
chain
.request()
.newBuilder()
.header(X_DATADOG_TEST_SESSION_TOKEN, testSessionToken)
.build()))
.build();
}

/** Registers a callback to be called when remote communications resume. */
public void whenReady(Runnable callback) {
if (paused) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
!rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down Expand Up @@ -343,7 +343,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
!rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down Expand Up @@ -383,7 +383,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down Expand Up @@ -421,7 +421,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger == null, 'test trigger found'

rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()
}

void 'test request body collection if WAF event with default-config'(){
Expand Down Expand Up @@ -457,7 +457,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
!rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def stack = rootSpan.span.metaStruct.get('_dd.stack')
assert stack != null, 'stack is not set'
def exploit = stack.get('exploit')
Expand Down Expand Up @@ -774,7 +774,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
variant | _
Expand Down Expand Up @@ -814,7 +814,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
variant | _
Expand Down Expand Up @@ -853,7 +853,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()
}

def findFirstMatchingSpan(String resource) {
Expand Down Expand Up @@ -939,7 +939,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
endpoint | cmd | params
Expand Down Expand Up @@ -990,7 +990,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
endpoint | cmd | params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class TracerConfig {
public static final String PROXY_NO_PROXY = "proxy.no_proxy";
public static final String TRACE_AGENT_PATH = "trace.agent.path";
public static final String TRACE_AGENT_ARGS = "trace.agent.args";
public static final String TEST_AGENT_SESSION_TOKEN = "test.agent.session.token";
public static final String PRIORITY_SAMPLING = "priority.sampling";
public static final String PRIORITY_SAMPLING_FORCE = "priority.sampling.force";
@Deprecated public static final String TRACE_RESOLVER_ENABLED = "trace.resolver.enabled";
Expand Down
7 changes: 7 additions & 0 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@
import static datadog.trace.api.config.TracerConfig.SPAN_SAMPLING_RULES_FILE;
import static datadog.trace.api.config.TracerConfig.SPAN_TAGS;
import static datadog.trace.api.config.TracerConfig.SPLIT_BY_TAGS;
import static datadog.trace.api.config.TracerConfig.TEST_AGENT_SESSION_TOKEN;
import static datadog.trace.api.config.TracerConfig.TRACE_128_BIT_TRACEID_GENERATION_ENABLED;
import static datadog.trace.api.config.TracerConfig.TRACE_AGENT_ARGS;
import static datadog.trace.api.config.TracerConfig.TRACE_AGENT_PATH;
Expand Down Expand Up @@ -1389,6 +1390,7 @@ public static String getHostName() {
private final boolean azureFunctions;
private final boolean awsServerless;
private final String traceAgentPath;
private final String testAgentSessionToken;
private final List<String> traceAgentArgs;
private final String dogStatsDPath;
private final List<String> dogStatsDArgs;
Expand Down Expand Up @@ -3199,6 +3201,7 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())

azureAppServices = configProvider.getBoolean(AZURE_APP_SERVICES, false);
traceAgentPath = configProvider.getString(TRACE_AGENT_PATH);
testAgentSessionToken = configProvider.getString(TEST_AGENT_SESSION_TOKEN);
String traceAgentArgsString = configProvider.getString(TRACE_AGENT_ARGS);
if (traceAgentArgsString == null) {
traceAgentArgs = Collections.emptyList();
Expand Down Expand Up @@ -5186,6 +5189,10 @@ public String getTraceAgentPath() {
return traceAgentPath;
}

public String getTestAgentSessionToken() {
return testAgentSessionToken;
}

public List<String> getTraceAgentArgs() {
return traceAgentArgs;
}
Expand Down
8 changes: 8 additions & 0 deletions metadata/supported-configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,14 @@
"aliases": []
}
],
"DD_TEST_AGENT_SESSION_TOKEN": [
{
"version": "A",
"type": "string",
"default": null,
"aliases": []
}
],
"DD_TEST_FAILED_TEST_REPLAY_ENABLED": [
{
"version": "A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ public final class ConfigSetting {

private static final Set<String> CONFIG_FILTER_LIST =
new HashSet<>(
Arrays.asList("DD_API_KEY", "dd.api-key", "dd.profiling.api-key", "dd.profiling.apikey"));
Arrays.asList(
"DD_API_KEY",
"dd.api-key",
"dd.profiling.api-key",
"dd.profiling.apikey",
"test.agent.session.token",
"DD_TEST_AGENT_SESSION_TOKEN"));

public static ConfigSetting of(String key, Object value, ConfigOrigin origin) {
return new ConfigSetting(key, value, origin, ABSENT_SEQ_ID, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ void supportsEqualityCheck(
}

@TableTest({
"scenario | key | value | filteredValue",
"DD_API_KEY | DD_API_KEY | somevalue | <hidden> ",
"dd.api-key | dd.api-key | somevalue | <hidden> ",
"dd.profiling.api-key | dd.profiling.api-key | somevalue | <hidden> ",
"dd.profiling.apikey | dd.profiling.apikey | somevalue | <hidden> ",
"some.other.key | some.other.key | somevalue | somevalue "
"scenario | key | value | filteredValue",
"DD_API_KEY | DD_API_KEY | somevalue | <hidden> ",
"dd.api-key | dd.api-key | somevalue | <hidden> ",
"dd.profiling.api-key | dd.profiling.api-key | somevalue | <hidden> ",
"dd.profiling.apikey | dd.profiling.apikey | somevalue | <hidden> ",
"session token prop | test.agent.session.token | somevalue | <hidden> ",
"session token env | DD_TEST_AGENT_SESSION_TOKEN | somevalue | <hidden> ",
"some.other.key | some.other.key | somevalue | somevalue "
})
void filtersKeyValues(String key, String value, String filteredValue) {
assertEquals(filteredValue, ConfigSetting.of(key, value, ConfigOrigin.DEFAULT).stringValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package datadog.trace.test.agent.decoder.v04.raw;

import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;

import datadog.trace.test.agent.decoder.DecodedSpan;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -265,9 +267,9 @@ public SpanV04(
this.start = start;
this.duration = duration;
this.error = error;
this.meta = Collections.unmodifiableMap(meta);
this.metaStruct = metaStruct == null ? null : Collections.unmodifiableMap(metaStruct);
this.metrics = Collections.unmodifiableMap(metrics);
this.meta = unmodifiableMap(meta);
this.metaStruct = metaStruct == null ? emptyMap() : unmodifiableMap(metaStruct);
this.metrics = unmodifiableMap(metrics);
this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package datadog.trace.test.agent.decoder.v05.raw;

import static java.util.Collections.emptyMap;

import datadog.trace.test.agent.decoder.DecodedSpan;
import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -190,7 +192,7 @@ public Map<String, String> getMeta() {

public Map<String, Object> getMetaStruct() {
// XXX: meta_struct is not supported in v0.5.
return null;
return emptyMap();
}

public Map<String, Number> getMetrics() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package datadog.trace.test.agent.decoder.v1.raw;

import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;

import datadog.trace.test.agent.decoder.DecodedSpan;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -492,9 +494,9 @@ public SpanV1(
this.start = start;
this.duration = duration;
this.error = error;
this.meta = Collections.unmodifiableMap(meta);
this.metaStruct = metaStruct == null ? null : Collections.unmodifiableMap(metaStruct);
this.metrics = Collections.unmodifiableMap(metrics);
this.meta = unmodifiableMap(meta);
this.metaStruct = metaStruct == null ? emptyMap() : unmodifiableMap(metaStruct);
this.metrics = unmodifiableMap(metrics);
this.type = type;
}

Expand Down