Skip to content

Commit 87b0131

Browse files
authored
Merge branch 'master' into mattalp/additional-jvmstat-telemetry
2 parents 0715c4c + 22535c7 commit 87b0131

File tree

38 files changed

+395
-118
lines changed

38 files changed

+395
-118
lines changed

.github/workflows/system-tests.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: system-tests
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
# Cancel long-running jobs when a new commit is pushed
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
runs-on:
15+
group: APM Larger Runners
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
19+
with:
20+
submodules: 'recursive'
21+
fetch-depth: 0
22+
23+
- name: Cache Gradle dependencies
24+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
25+
with:
26+
path: |
27+
~/.gradle/caches
28+
~/.gradle/wrapper
29+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30+
restore-keys: |
31+
${{ runner.os }}-gradle-
32+
33+
- name: Build dd-trace-java
34+
run: |
35+
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G'" \
36+
JAVA_HOME=$JAVA_HOME_8_X64 \
37+
JAVA_8_HOME=$JAVA_HOME_8_X64 \
38+
JAVA_11_HOME=$JAVA_HOME_11_X64 \
39+
JAVA_17_HOME=$JAVA_HOME_17_X64 \
40+
JAVA_21_HOME=$JAVA_HOME_21_X64 \
41+
./gradlew clean :dd-java-agent:shadowJar \
42+
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
43+
44+
- name: Upload artifact
45+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
46+
with:
47+
name: binaries
48+
path: workspace/dd-java-agent/build/libs/
49+
50+
main:
51+
needs:
52+
- build
53+
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main
54+
secrets: inherit
55+
permissions:
56+
contents: read
57+
packages: write
58+
with:
59+
library: java
60+
binaries_artifact: binaries
61+
desired_execution_time: 900 # 15 minutes
62+
scenarios_groups: tracer-release
63+
excluded_scenarios: CROSSED_TRACING_LIBRARIES,INTEGRATIONS_AWS # require AWS credentials
64+
skip_empty_scenarios: true

buildSrc/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ dependencies {
3030
implementation(gradleApi())
3131
implementation(localGroovy())
3232

33-
implementation("net.bytebuddy", "byte-buddy-gradle-plugin", "1.14.18")
33+
implementation("net.bytebuddy", "byte-buddy-gradle-plugin", "1.15.11")
3434

3535
implementation("org.eclipse.aether", "aether-connector-basic", "1.1.0")
3636
implementation("org.eclipse.aether", "aether-transport-http", "1.1.0")
3737
implementation("org.apache.maven", "maven-aether-provider", "3.3.9")
3838

3939
implementation("com.google.guava", "guava", "20.0")
40-
implementation("org.ow2.asm", "asm", "9.7.1")
41-
implementation("org.ow2.asm", "asm-tree", "9.7.1")
40+
implementation("org.ow2.asm", "asm", "9.8")
41+
implementation("org.ow2.asm", "asm-tree", "9.8")
4242

4343
testImplementation("org.spockframework", "spock-core", "2.2-groovy-3.0")
4444
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ dependencies {
3232
compileOnly("com.google.code.findbugs", "jsr305", "3.0.2")
3333

3434
implementation("org.freemarker", "freemarker", "2.3.30")
35-
implementation("org.ow2.asm", "asm", "9.7.1")
36-
implementation("org.ow2.asm", "asm-tree", "9.7.1")
35+
implementation("org.ow2.asm", "asm", "9.8")
36+
implementation("org.ow2.asm", "asm-tree", "9.8")
3737
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
3838

39-
testImplementation("net.bytebuddy", "byte-buddy", "1.14.18")
39+
testImplementation("net.bytebuddy", "byte-buddy", "1.15.11")
4040
testImplementation("org.spockframework", "spock-core", "2.0-groovy-3.0")
4141
testImplementation("org.objenesis", "objenesis", "3.0.1")
4242
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")

buildSrc/src/test/groovy/CallSiteInstrumentationPluginTest.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CallSiteInstrumentationPluginTest extends Specification {
2727
}
2828
2929
dependencies {
30-
implementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.18'
30+
implementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.15.11'
3131
implementation group: 'com.google.auto.service', name: 'auto-service-annotations', version: '1.0-rc7'
3232
}
3333
'''

buildSrc/src/test/groovy/InstrumentPluginTest.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class InstrumentPluginTest extends Specification {
2323
}
2424
2525
dependencies {
26-
compileOnly group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.18' // just to build TestPlugin
26+
compileOnly group: 'net.bytebuddy', name: 'byte-buddy', version: '1.15.11' // just to build TestPlugin
2727
}
2828
2929
apply plugin: 'instrument'

dd-java-agent/agent-crashtracking/src/main/java/com/datadog/crashtracking/CrashUploader.java

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public void upload(@Nonnull List<Path> files) throws IOException {
121121
}
122122
}
123123

124+
@SuppressForbidden
124125
boolean uploadToLogs(@Nonnull Path file) {
125126
try {
126127
uploadToLogs(new String(Files.readAllBytes(file), StandardCharsets.UTF_8), System.out);
@@ -156,6 +157,7 @@ void uploadToLogs(@Nonnull String message, @Nonnull PrintStream out) throws IOEx
156157
}
157158

158159
// @VisibleForTesting
160+
@SuppressForbidden
159161
static String extractErrorKind(String fileContent) {
160162
Matcher matcher = ERROR_MESSAGE_PATTERN.matcher(fileContent);
161163
if (!matcher.find()) {

dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/el/ValueReferences.java

+4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ public final class ValueReferences {
1414
public static String RETURN_EXTENSION_NAME = "return";
1515
public static String ITERATOR_EXTENSION_NAME = "it";
1616
public static String EXCEPTION_EXTENSION_NAME = "exception";
17+
public static String KEY_EXTENSION_NAME = "key";
18+
public static String VALUE_EXTENSION_NAME = "value";
1719
public static String DURATION_REF = SYNTHETIC_PREFIX + DURATION_EXTENSION_NAME;
1820
public static String RETURN_REF = SYNTHETIC_PREFIX + RETURN_EXTENSION_NAME;
1921
public static String ITERATOR_REF = SYNTHETIC_PREFIX + ITERATOR_EXTENSION_NAME;
2022
public static String EXCEPTION_REF = SYNTHETIC_PREFIX + EXCEPTION_EXTENSION_NAME;
23+
public static String KEY_REF = SYNTHETIC_PREFIX + KEY_EXTENSION_NAME;
24+
public static String VALUE_REF = SYNTHETIC_PREFIX + VALUE_EXTENSION_NAME;
2125

2226
public static String synthetic(String name) {
2327
return SYNTHETIC_PREFIX + name;

dd-java-agent/agent-debugger/debugger-el/src/main/java/com/datadog/debugger/el/PrettyPrintVisitor.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,27 @@ public String visit(EndsWithExpression endsWithExpression) {
8989
public String visit(FilterCollectionExpression filterCollectionExpression) {
9090
return "filter("
9191
+ nullSafeAccept(filterCollectionExpression.getSource())
92-
+ ", "
92+
+ ", {"
9393
+ nullSafeAccept(filterCollectionExpression.getFilterExpression())
94-
+ ")";
94+
+ "})";
9595
}
9696

9797
@Override
9898
public String visit(HasAllExpression hasAllExpression) {
9999
return "all("
100100
+ nullSafeAccept(hasAllExpression.getValueExpression())
101-
+ ", "
101+
+ ", {"
102102
+ nullSafeAccept(hasAllExpression.getFilterPredicateExpression())
103-
+ ")";
103+
+ "})";
104104
}
105105

106106
@Override
107107
public String visit(HasAnyExpression hasAnyExpression) {
108108
return "any("
109109
+ nullSafeAccept(hasAnyExpression.getValueExpression())
110-
+ ", "
110+
+ ", {"
111111
+ nullSafeAccept(hasAnyExpression.getFilterPredicateExpression())
112-
+ ")";
112+
+ "})";
113113
}
114114

115115
@Override

dd-java-agent/agent-debugger/debugger-el/src/main/java/com/datadog/debugger/el/expressions/FilterCollectionExpression.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ public CollectionValue<?> evaluate(ValueReferenceResolver valueRefResolver) {
5858
} else if (collectionValue instanceof MapValue) {
5959
MapValue materialized = (MapValue) collectionValue;
6060
Map<Object, Object> filtered = new HashMap<>();
61-
6261
for (Value<?> key : materialized.getKeys()) {
6362
Value<?> value = key.isUndefined() ? Value.undefinedValue() : materialized.get(key);
64-
if (filterExpression.evaluate(
65-
valueRefResolver.withExtensions(
66-
Collections.singletonMap(
67-
ValueReferences.ITERATOR_EXTENSION_NAME, new MapValue.Entry(key, value))))) {
63+
Map<String, Object> valueRefExtensions = new HashMap<>();
64+
valueRefExtensions.put(ValueReferences.KEY_EXTENSION_NAME, key);
65+
valueRefExtensions.put(ValueReferences.VALUE_EXTENSION_NAME, value);
66+
valueRefExtensions.put(
67+
ValueReferences.ITERATOR_EXTENSION_NAME, new MapValue.Entry(key, value));
68+
if (filterExpression.evaluate(valueRefResolver.withExtensions(valueRefExtensions))) {
6869
filtered.put(key.getValue(), value.getValue());
6970
}
7071
}

dd-java-agent/agent-debugger/debugger-el/src/main/java/com/datadog/debugger/el/expressions/HasAllExpression.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import datadog.trace.bootstrap.debugger.el.ValueReferences;
1212
import datadog.trace.bootstrap.debugger.util.WellKnownClasses;
1313
import java.util.Collections;
14+
import java.util.HashMap;
15+
import java.util.Map;
1416
import java.util.Set;
1517

1618
/**
@@ -65,10 +67,13 @@ public Boolean evaluate(ValueReferenceResolver valueRefResolver) {
6567
}
6668
for (Value<?> key : map.getKeys()) {
6769
Value<?> val = key.isUndefined() ? Value.undefinedValue() : map.get(key);
70+
Map<String, Object> valueRefExtensions = new HashMap<>();
71+
valueRefExtensions.put(ValueReferences.KEY_EXTENSION_NAME, key);
72+
valueRefExtensions.put(ValueReferences.VALUE_EXTENSION_NAME, val);
73+
valueRefExtensions.put(
74+
ValueReferences.ITERATOR_EXTENSION_NAME, new MapValue.Entry(key, val));
6875
if (!filterPredicateExpression.evaluate(
69-
valueRefResolver.withExtensions(
70-
Collections.singletonMap(
71-
ValueReferences.ITERATOR_EXTENSION_NAME, new MapValue.Entry(key, val))))) {
76+
valueRefResolver.withExtensions(valueRefExtensions))) {
7277
return Boolean.FALSE;
7378
}
7479
}

dd-java-agent/agent-debugger/debugger-el/src/main/java/com/datadog/debugger/el/expressions/HasAnyExpression.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import datadog.trace.bootstrap.debugger.el.ValueReferences;
1212
import datadog.trace.bootstrap.debugger.util.WellKnownClasses;
1313
import java.util.Collections;
14+
import java.util.HashMap;
15+
import java.util.Map;
1416
import java.util.Set;
1517

1618
/**
@@ -65,11 +67,13 @@ public Boolean evaluate(ValueReferenceResolver valueRefResolver) {
6567
}
6668
for (Value<?> key : map.getKeys()) {
6769
Value<?> val = key.isUndefined() ? Value.undefinedValue() : map.get(key);
68-
70+
Map<String, Object> valueRefExtensions = new HashMap<>();
71+
valueRefExtensions.put(ValueReferences.KEY_EXTENSION_NAME, key);
72+
valueRefExtensions.put(ValueReferences.VALUE_EXTENSION_NAME, val);
73+
valueRefExtensions.put(
74+
ValueReferences.ITERATOR_EXTENSION_NAME, new MapValue.Entry(key, val));
6975
if (filterPredicateExpression.evaluate(
70-
valueRefResolver.withExtensions(
71-
Collections.singletonMap(
72-
ValueReferences.ITERATOR_EXTENSION_NAME, new MapValue.Entry(key, val))))) {
76+
valueRefResolver.withExtensions(valueRefExtensions))) {
7377
return Boolean.TRUE;
7478
}
7579
}

dd-java-agent/agent-debugger/debugger-el/src/test/java/com/datadog/debugger/el/expressions/FilterCollectionExpressionTest.java

+33-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void testMatchingList() {
2828
assertFalse(filtered.isEmpty());
2929
assertFalse(filtered.isNull());
3030
assertFalse(filtered.isUndefined());
31-
assertEquals("filter(int[], @it < 2)", print(expression));
31+
assertEquals("filter(int[], {@it < 2})", print(expression));
3232
}
3333

3434
@Test
@@ -41,7 +41,7 @@ void testEmptyList() {
4141
assertTrue(filtered.isEmpty());
4242
assertFalse(filtered.isNull());
4343
assertFalse(filtered.isUndefined());
44-
assertEquals("filter(int[], @it < 2)", print(expression));
44+
assertEquals("filter(int[], {@it < 2})", print(expression));
4545
}
4646

4747
@Test
@@ -52,7 +52,7 @@ void testNullList() {
5252
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
5353
assertEquals(collection, filtered);
5454
assertTrue(filtered.isNull());
55-
assertEquals("filter(null, @it < 2)", print(expression));
55+
assertEquals("filter(null, {@it < 2})", print(expression));
5656
}
5757

5858
@Test
@@ -63,7 +63,7 @@ void testNullObjectList() {
6363
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
6464
assertEquals(collection, filtered);
6565
assertTrue(filtered.isNull());
66-
assertEquals("filter(null, @it < 2)", print(expression));
66+
assertEquals("filter(null, {@it < 2})", print(expression));
6767
}
6868

6969
@Test
@@ -74,7 +74,7 @@ void testUndefinedList() {
7474
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
7575
assertEquals(collection, filtered);
7676
assertTrue(filtered.isUndefined());
77-
assertEquals("filter(null, @it < 2)", print(expression));
77+
assertEquals("filter(null, {@it < 2})", print(expression));
7878
}
7979

8080
@Test
@@ -104,7 +104,7 @@ void testMatchingMap() {
104104
assertFalse(filtered.isEmpty());
105105
assertFalse(filtered.isNull());
106106
assertFalse(filtered.isUndefined());
107-
assertEquals("filter(Map, @it.value < 2)", print(expression));
107+
assertEquals("filter(Map, {@it.value < 2})", print(expression));
108108
}
109109

110110
@Test
@@ -117,7 +117,7 @@ void testEmptyMap() {
117117
assertTrue(filtered.isEmpty());
118118
assertFalse(filtered.isNull());
119119
assertFalse(filtered.isUndefined());
120-
assertEquals("filter(Map, @it < 2)", print(expression));
120+
assertEquals("filter(Map, {@it < 2})", print(expression));
121121
}
122122

123123
@Test
@@ -128,7 +128,7 @@ void testNullMap() {
128128
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
129129
assertEquals(collection, filtered);
130130
assertTrue(filtered.isNull());
131-
assertEquals("filter(null, @it < 2)", print(expression));
131+
assertEquals("filter(null, {@it < 2})", print(expression));
132132
}
133133

134134
@Test
@@ -139,7 +139,7 @@ void testNullObjectMap() {
139139
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
140140
assertEquals(collection, filtered);
141141
assertTrue(filtered.isNull());
142-
assertEquals("filter(null, @it < 2)", print(expression));
142+
assertEquals("filter(null, {@it < 2})", print(expression));
143143
}
144144

145145
@Test
@@ -150,6 +150,29 @@ void testUndefinedMap() {
150150
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
151151
assertEquals(collection, filtered);
152152
assertTrue(filtered.isUndefined());
153-
assertEquals("filter(null, @it < 2)", print(expression));
153+
assertEquals("filter(null, {@it < 2})", print(expression));
154+
}
155+
156+
@Test
157+
void keyValueMap() {
158+
Map<String, Integer> map = new HashMap<>();
159+
map.put("a", 1);
160+
map.put("b", 2);
161+
map.put("c", 3);
162+
MapValue collection = new MapValue(map);
163+
164+
FilterCollectionExpression expression =
165+
new FilterCollectionExpression(collection, eq(ref(ValueReferences.KEY_REF), value("b")));
166+
CollectionValue<?> filtered = expression.evaluate(RefResolverHelper.createResolver(this));
167+
assertNotEquals(collection, filtered);
168+
assertEquals(1, filtered.count());
169+
assertEquals("filter(Map, {@key == \"b\"})", print(expression));
170+
171+
expression =
172+
new FilterCollectionExpression(collection, eq(ref(ValueReferences.VALUE_REF), value(2)));
173+
filtered = expression.evaluate(RefResolverHelper.createResolver(this));
174+
assertNotEquals(collection, filtered);
175+
assertEquals(1, filtered.count());
176+
assertEquals("filter(Map, {@value == 2})", print(expression));
154177
}
155178
}

0 commit comments

Comments
 (0)