Skip to content

Commit

Permalink
Merge branch 'master' into rgs/q-length
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik authored Jan 23, 2025
2 parents 096b145 + 56d4919 commit 4ac25d4
Show file tree
Hide file tree
Showing 1,246 changed files with 67,397 additions and 55,104 deletions.
25 changes: 24 additions & 1 deletion .circleci/collect_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This folder will be saved by circleci and available after test runs.

set -e
#Enable '**' support
# Enable '**' support
shopt -s globstar

TEST_RESULTS_DIR=results
Expand All @@ -19,13 +19,36 @@ if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then
exit 0
fi

function get_source_file () {
file_path="${RESULT_XML_FILE%%"/build"*}"
file_path="${file_path/#"$WORKSPACE_DIR"\//}/src"
if ! [[ $RESULT_XML_FILE == *"#"* ]]; then
class="${RESULT_XML_FILE%.xml}"
class="${class##*"TEST-"}"
class="${class##*"."}"
common_root=$(grep -rl "class $class" "$file_path" | head -n 1)
while IFS= read -r line; do
while [[ $line != "$common_root"* ]]; do
common_root=$(dirname "$common_root")
if [[ "$common_root" == "$common_root/.." ]]; then
break
fi
done
done < <(grep -rl "class $class" "$file_path")
file_path="$common_root"
fi
}

echo "Saving test results:"
while IFS= read -r -d '' RESULT_XML_FILE
do
echo -n "- $RESULT_XML_FILE"
AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
echo -n " as $AGGREGATED_FILE_NAME"
cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
# Insert file attribute to testcase XML nodes
get_source_file
sed -i "/<testcase/ s|\(time=\"[^\"]*\"\)|\1 file=\"$file_path\"|g" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
# Replace random port numbers by marker in testcase XML nodes to get stable test names
Expand Down
11 changes: 10 additions & 1 deletion .circleci/config.continue.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"

default_system_tests_commit: &default_system_tests_commit 2cb5033072c1813eccdce332153a378607e73d85
default_system_tests_commit: &default_system_tests_commit 8b05076e897fe62206d7704f2e8e650ed83ebd1f

parameters:
nightly:
Expand Down Expand Up @@ -422,6 +422,7 @@ jobs:
-PgitBaseRef=origin/{{ pr_base_ref }}
{% endif %}
-PrunBuildSrcTests
-PskipSpotless
-PtaskPartitionCount=${CIRCLE_NODE_TOTAL} -PtaskPartition=${CIRCLE_NODE_INDEX}
<< pipeline.parameters.gradle_flags >>
--max-workers=8
Expand Down Expand Up @@ -1107,12 +1108,20 @@ build_test_jobs: &build_test_jobs
gradleTarget: ":profilingCheck"
cacheType: profiling
- check:
requires:
- ok_to_test
name: check_debugger
gradleTarget: ":debuggerCheck"
cacheType: base
- fan_in:
requires:
- check_base
- check_inst
- check_smoke
- check_profiling
- check_debugger
name: check
stage: check
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dd-java-agent/instrumentation/testng/ @DataDog/ci-app-libraries-java
dd-java-agent/instrumentation/gradle-3.0/ @DataDog/ci-app-libraries-java
dd-java-agent/instrumentation/gradle-8.3/ @DataDog/ci-app-libraries-java
dd-java-agent/instrumentation/maven-3.2.1/ @DataDog/ci-app-libraries-java
dd-java-agent/instrumentation/weaver/ @DataDog/ci-app-libraries-java
dd-smoke-tests/gradle/ @DataDog/ci-app-libraries-java
dd-smoke-tests/maven/ @DataDog/ci-app-libraries-java
**/civisibility/ @DataDog/ci-app-libraries-java
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/analyze-changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
submodules: 'recursive'

- name: Cache Gradle dependencies
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.gradle/caches
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
submodules: 'recursive'

- name: Cache Gradle dependencies
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.gradle/caches
Expand Down
2 changes: 1 addition & 1 deletion communication/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ com.thoughtworks.qdox:qdox:1.12.1=testRuntimeClasspath
commons-codec:commons-codec:1.15=spotbugs
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testRuntimeClasspath
commons-io:commons-io:2.11.0=testCompileClasspath,testRuntimeClasspath
de.thetaphi:forbiddenapis:3.1=compileClasspath
de.thetaphi:forbiddenapis:3.8=compileClasspath
info.picocli:picocli:4.6.3=testRuntimeClasspath
jaxen:jaxen:1.2.0=spotbugs
jline:jline:2.14.6=testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import datadog.trace.test.util.DDSpecification
import okhttp3.HttpUrl
import okhttp3.OkHttpClient

import static datadog.trace.api.config.TracerConfig.AGENT_HOST

class SharedCommunicationsObjectsSpecification extends DDSpecification {
SharedCommunicationObjects sco = new SharedCommunicationObjects()

Expand Down Expand Up @@ -90,4 +92,36 @@ class SharedCommunicationsObjectsSpecification extends DDSpecification {
sco.monitoring.is(monitoring)
sco.featuresDiscovery.is(agentFeaturesDiscovery)
}

void 'supports ipv6 agent host w/o brackets'() {
given:
injectSysConfig(AGENT_HOST, "2600:1f18:19c0:bd07:d55b::17")
Config config = Mock()

when:
sco.createRemaining(config)

then:
1 * config.getAgentUrl() >> 'http://[2600:1f18:19c0:bd07:d55b::17]:8126'
1 * config.agentNamedPipe >> null
1 * config.agentTimeout >> 1
1 * config.agentUnixDomainSocket >> null
sco.agentUrl as String == 'http://[2600:1f18:19c0:bd07:d55b::17]:8126/'
}

void 'supports ipv6 agent host w/ brackets'() {
given:
injectSysConfig(AGENT_HOST, "[2600:1f18:19c0:bd07:d55b::17]")
Config config = Mock()

when:
sco.createRemaining(config)

then:
1 * config.getAgentUrl() >> 'http://[2600:1f18:19c0:bd07:d55b::17]:8126'
1 * config.agentNamedPipe >> null
1 * config.agentTimeout >> 1
1 * config.agentUnixDomainSocket >> null
sco.agentUrl as String == 'http://[2600:1f18:19c0:bd07:d55b::17]:8126/'
}
}
2 changes: 1 addition & 1 deletion components/context/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ com.google.code.findbugs:jsr305:3.0.2=compileClasspath,jmhCompileClasspath,jmhRu
com.google.code.gson:gson:2.9.1=spotbugs
com.thoughtworks.qdox:qdox:1.12.1=jmhRuntimeClasspath,testRuntimeClasspath
commons-codec:commons-codec:1.15=spotbugs
de.thetaphi:forbiddenapis:3.1=compileClasspath,jmhCompileClasspath
de.thetaphi:forbiddenapis:3.8=compileClasspath,jmhCompileClasspath
info.picocli:picocli:4.6.3=jmhRuntimeClasspath,testRuntimeClasspath
jaxen:jaxen:1.2.0=spotbugs
jline:jline:2.14.6=jmhRuntimeClasspath,testRuntimeClasspath
Expand Down
24 changes: 23 additions & 1 deletion components/context/src/main/java/datadog/context/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static Context detachFrom(Object carrier) {
/**
* Creates a copy of this context with the given key-value set.
*
* <p>Existing value with the given key will be replaced, and mapping to a {@code null} value will
* <p>Existing value with the given key will be replaced. Mapping to a {@code null} value will
* remove the key-value from the context copy.
*
* @param <T> the type of the value.
Expand All @@ -124,6 +124,28 @@ static Context detachFrom(Object carrier) {
*/
<T> Context with(ContextKey<T> key, @Nullable T value);

/**
* Creates a copy of this context with the given pair of key-values.
*
* <p>Existing values with the given keys will be replaced. Mapping to a {@code null} value will
* remove the key-value from the context copy.
*
* @param <T> the type of the first value.
* @param <U> the type of the second value.
* @param firstKey the first key to store the first value.
* @param firstValue the first value to store.
* @param secondKey the second key to store the second value.
* @param secondValue the second value to store.
* @return a new context with the pair of key-values set.
*/
default <T, U> Context with(
ContextKey<T> firstKey,
@Nullable T firstValue,
ContextKey<U> secondKey,
@Nullable U secondValue) {
return with(firstKey, firstValue).with(secondKey, secondValue);
}

/**
* Creates a copy of this context with the implicit key is mapped to the value.
*
Expand Down
35 changes: 35 additions & 0 deletions components/context/src/test/java/datadog/context/ContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,41 @@ void testWith(Context context) {
assertDoesNotThrow(() -> context.with(null), "Null implicitly keyed value not throw exception");
}

@ParameterizedTest
@MethodSource("contextImplementations")
void testWithPair(Context context) {
// Test retrieving value
String stringValue = "value";
Context context1 = context.with(BOOLEAN_KEY, false, STRING_KEY, stringValue);
assertEquals(stringValue, context1.get(STRING_KEY));
assertEquals(false, context1.get(BOOLEAN_KEY));
// Test overriding value
String stringValue2 = "value2";
Context context2 = context1.with(STRING_KEY, stringValue2, BOOLEAN_KEY, true);
assertEquals(stringValue2, context2.get(STRING_KEY));
assertEquals(true, context2.get(BOOLEAN_KEY));
// Test clearing value
Context context3 = context2.with(BOOLEAN_KEY, null, STRING_KEY, null);
assertNull(context3.get(STRING_KEY));
assertNull(context3.get(BOOLEAN_KEY));
// Test null key handling
assertThrows(
NullPointerException.class,
() -> context.with(null, "test", STRING_KEY, "test"),
"Context forbids null keys");
assertThrows(
NullPointerException.class,
() -> context.with(STRING_KEY, "test", null, "test"),
"Context forbids null keys");
// Test null value handling
assertDoesNotThrow(
() -> context.with(BOOLEAN_KEY, null, STRING_KEY, "test"),
"Null value should not throw exception");
assertDoesNotThrow(
() -> context.with(STRING_KEY, "test", BOOLEAN_KEY, null),
"Null value should not throw exception");
}

@ParameterizedTest
@MethodSource("contextImplementations")
void testGet(Context original) {
Expand Down
2 changes: 1 addition & 1 deletion components/json/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ com.google.code.findbugs:jsr305:3.0.2=compileClasspath,jmhCompileClasspath,jmhRu
com.google.code.gson:gson:2.9.1=spotbugs
com.thoughtworks.qdox:qdox:1.12.1=jmhRuntimeClasspath,testRuntimeClasspath
commons-codec:commons-codec:1.15=spotbugs
de.thetaphi:forbiddenapis:3.1=compileClasspath,jmhCompileClasspath
de.thetaphi:forbiddenapis:3.8=compileClasspath,jmhCompileClasspath
info.picocli:picocli:4.6.3=jmhRuntimeClasspath,testRuntimeClasspath
jaxen:jaxen:1.2.0=spotbugs
jline:jline:2.14.6=jmhRuntimeClasspath,testRuntimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/agent-bootstrap/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ com.thoughtworks.qdox:qdox:1.12.1=jmhRuntimeClasspath,testRuntimeClasspath
commons-codec:commons-codec:1.15=spotbugs
commons-fileupload:commons-fileupload:1.5=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
commons-io:commons-io:2.11.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
de.thetaphi:forbiddenapis:3.1=compileClasspath,jmhCompileClasspath
de.thetaphi:forbiddenapis:3.8=compileClasspath,jmhCompileClasspath
info.picocli:picocli:4.6.3=jmhRuntimeClasspath,testRuntimeClasspath
io.sqreen:libsqreen:11.2.0=jmhRuntimeClasspath,testRuntimeClasspath
javax.servlet:javax.servlet-api:3.1.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class Constants {
*/
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
"datadog.slf4j",
"datadog.context",
"datadog.appsec.api",
"datadog.trace.api",
"datadog.trace.bootstrap",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,7 @@ public String getDbType() {
public AgentSpan onConnection(final AgentSpan span, final CONNECTION connection) {
if (connection != null) {
span.setTag(Tags.DB_USER, dbUser(connection));
final String instanceName = dbInstance(connection);
span.setTag(Tags.DB_INSTANCE, instanceName);

String serviceName = dbClientService(instanceName);
if (null != serviceName) {
span.setServiceName(serviceName);
}

onInstance(span, dbInstance(connection));
CharSequence hostName = dbHostname(connection);
if (hostName != null) {
span.setTag(Tags.PEER_HOSTNAME, hostName);
Expand All @@ -90,6 +83,17 @@ public AgentSpan onConnection(final AgentSpan span, final CONNECTION connection)
return span;
}

protected AgentSpan onInstance(final AgentSpan span, final String dbInstance) {
if (dbInstance != null) {
span.setTag(Tags.DB_INSTANCE, dbInstance);
String serviceName = dbClientService(dbInstance);
if (null != serviceName) {
span.setServiceName(serviceName);
}
}
return span;
}

public String dbService(final String dbType, final String instanceName) {
if (instanceName != null && Config.get().isDbClientSplitByInstance()) {
return dbClientService(instanceName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog.trace.bootstrap.instrumentation.java.concurrent;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.setAsyncPropagationEnabled;

import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
Expand All @@ -26,7 +27,7 @@ public static AgentScope startTaskScope(State state) {
final AgentScope.Continuation continuation = state.getAndResetContinuation();
if (continuation != null) {
final AgentScope scope = continuation.activate();
scope.setAsyncPropagation(true);
setAsyncPropagationEnabled(true);
// important - stop timing after the scope has been activated so the time in the queue can
// be attributed to the correct context without duplicating the propagated information
state.stopTiming();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
then:
if (session) {
1 * span.setTag(Tags.DB_USER, session.user)
1 * span.setTag(Tags.DB_INSTANCE, session.instance)
if (session.instance != null) {
1 * span.setTag(Tags.DB_INSTANCE, session.instance)
}
if (session.hostname != null) {
1 * span.setTag(Tags.PEER_HOSTNAME, session.hostname)
}
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/agent-builder/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ com.thoughtworks.qdox:qdox:1.12.1=testRuntimeClasspath
commons-codec:commons-codec:1.15=spotbugs
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testRuntimeClasspath
commons-io:commons-io:2.11.0=testCompileClasspath,testRuntimeClasspath
de.thetaphi:forbiddenapis:3.1=compileClasspath
de.thetaphi:forbiddenapis:3.8=compileClasspath
info.picocli:picocli:4.6.3=testRuntimeClasspath
io.sqreen:libsqreen:11.2.0=testRuntimeClasspath
javax.servlet:javax.servlet-api:3.1.0=testCompileClasspath,testRuntimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/agent-ci-visibility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
testFixturesApi project(':utils:test-utils')

testFixturesApi group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
testFixturesApi group: 'org.freemarker', name: 'freemarker', version: '2.3.30'
testFixturesApi group: 'org.freemarker', name: 'freemarker', version: '2.3.31'
testFixturesApi group: 'com.jayway.jsonpath', name: 'json-path', version: '2.8.0'
testFixturesApi group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.0'
testFixturesApi group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.6'
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/agent-ci-visibility/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ com.vaadin.external.google:android-json:0.0.20131108.vaadin1=testCompileClasspat
commons-codec:commons-codec:1.15=spotbugs
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testFixturesApiDependenciesMetadata,testFixturesCompileClasspath,testFixturesImplementationDependenciesMetadata,testFixturesRuntimeClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
commons-io:commons-io:2.11.0=testCompileClasspath,testFixturesApiDependenciesMetadata,testFixturesCompileClasspath,testFixturesImplementationDependenciesMetadata,testFixturesRuntimeClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
de.thetaphi:forbiddenapis:3.1=compileClasspath,compileOnlyDependenciesMetadata
de.thetaphi:forbiddenapis:3.8=compileClasspath,compileOnlyDependenciesMetadata
info.picocli:picocli:4.6.3=testFixturesRuntimeClasspath,testRuntimeClasspath
io.github.java-diff-utils:java-diff-utils:4.12=zinc
io.sqreen:libsqreen:11.2.0=testFixturesRuntimeClasspath,testRuntimeClasspath
Expand Down
Loading

0 comments on commit 4ac25d4

Please sign in to comment.