Skip to content

Commit 59e939e

Browse files
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
2 parents 1ddcaf3 + c17d0e8 commit 59e939e

File tree

59 files changed

+927
-706
lines changed

Some content is hidden

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

59 files changed

+927
-706
lines changed

.gitlab-ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ default:
132132
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
133133
stage: build
134134
variables:
135-
MAVEN_OPTS: "-Xms64M -Xmx512M"
135+
MAVEN_OPTS: "-Xms256M -Xmx1024M"
136136
GRADLE_WORKERS: 2
137-
GRADLE_MEM: 2560M
137+
GRADLE_MEM: 3G
138138
KUBERNETES_CPU_REQUEST: 8
139-
KUBERNETES_MEMORY_REQUEST: 8Gi
140-
KUBERNETES_MEMORY_LIMIT: 8Gi
139+
KUBERNETES_MEMORY_REQUEST: 10Gi
140+
KUBERNETES_MEMORY_LIMIT: 10Gi
141141
CACHE_TYPE: "lib" #default
142142
FF_USE_FASTZIP: "true"
143143
CACHE_COMPRESSION_LEVEL: "slowest"
@@ -289,8 +289,7 @@ build_tests:
289289
CACHE_TYPE: "latestdep"
290290
- GRADLE_TARGET: ":smokeTest"
291291
CACHE_TYPE: "smoke"
292-
MAVEN_OPTS: "-Xms64M -Xmx512M"
293-
292+
MAVEN_OPTS: "-Xms256M -Xmx1024M"
294293
script:
295294
- *gitlab_base_ref_params
296295
- ./gradlew --version

.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 0 additions & 118 deletions
This file was deleted.

.mvn/wrapper/maven-wrapper.jar

-49.5 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.9/apache-maven-3.8.9-bin.zip

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ testing {
8686
suites {
8787
val test by getting(JvmTestSuite::class) {
8888
dependencies {
89-
implementation(libs.spock.core)
9089
implementation(libs.groovy)
90+
implementation(libs.spock.core)
9191
}
9292
targets.configureEach {
9393
testTask.configure {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ dependencies {
3535
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
3636

3737
testImplementation(libs.bytebuddy)
38-
testImplementation(libs.spock.core)
39-
testImplementation("org.objenesis", "objenesis", "3.0.1")
4038
testImplementation(libs.groovy)
39+
testImplementation(libs.bundles.spock)
4140
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
4241
testImplementation(libs.spotbugs.annotations)
4342
}

communication/src/main/java/datadog/communication/monitor/DDAgentStatsDClientManager.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.LOGGING_WRITER_TYPE;
44

55
import datadog.trace.api.Config;
6+
import datadog.trace.api.ProcessTags;
67
import datadog.trace.api.StatsDClient;
78
import datadog.trace.api.StatsDClientManager;
89
import datadog.trace.api.cache.DDCache;
910
import datadog.trace.api.cache.DDCaches;
11+
import java.util.List;
1012
import java.util.concurrent.ConcurrentHashMap;
1113
import java.util.concurrent.atomic.AtomicInteger;
1214
import java.util.function.Function;
@@ -54,8 +56,30 @@ public StatsDClient statsDClient(
5456
nameMapping = new NameResolver(namespace);
5557
}
5658

57-
if (null != constantTags && constantTags.length > 0) {
58-
tagMapping = new TagCombiner(constantTags);
59+
final List<String> processTags = ProcessTags.getTagsAsStringList();
60+
final int processTagSize = processTags != null ? processTags.size() : 0;
61+
String[] finalConstantTags = constantTags;
62+
if (processTagSize > 0) {
63+
final int constantTagSize = constantTags != null ? constantTags.length : 0;
64+
if (constantTagSize == 0) {
65+
finalConstantTags = processTags.toArray(new String[0]);
66+
} else {
67+
final int tagSizeSum = processTagSize + constantTagSize;
68+
finalConstantTags = new String[tagSizeSum];
69+
int pos = 0;
70+
// copy constant tags
71+
for (; pos < constantTagSize; pos++) {
72+
finalConstantTags[pos] = constantTags[pos];
73+
}
74+
// copy process tags
75+
for (int i = 0; i < processTagSize; i++) {
76+
finalConstantTags[pos + i] = processTags.get(i);
77+
}
78+
}
79+
}
80+
81+
if (null != finalConstantTags && finalConstantTags.length > 0) {
82+
tagMapping = new TagCombiner(finalConstantTags);
5983
}
6084

6185
if (USE_LOGGING_CLIENT) {

communication/src/test/groovy/datadog/communication/http/RejectingExecutorServiceTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package datadog.communication.http
22

3+
import static org.junit.jupiter.api.Assertions.assertThrows
4+
35
import org.junit.jupiter.api.Test
46

57
import java.util.concurrent.ExecutorService
68
import java.util.concurrent.RejectedExecutionException
79
import java.util.concurrent.TimeUnit
810

9-
import static groovy.test.GroovyAssert.shouldFail
10-
1111
class RejectingExecutorServiceTest {
1212
ExecutorService executorService = new RejectingExecutorService()
1313

1414
@Test
1515
void 'execute throws exception'() {
16-
shouldFail(RejectedExecutionException) {
16+
assertThrows(RejectedExecutionException) {
1717
executorService.execute({})
1818
}
1919
}

communication/src/test/groovy/datadog/communication/monitor/DDAgentStatsDClientTest.groovy

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package datadog.communication.monitor
22

3+
import static datadog.trace.api.config.GeneralConfig.EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED
34

5+
import datadog.trace.api.ProcessTags
46
import datadog.trace.test.util.DDSpecification
57

68
import static datadog.trace.api.config.GeneralConfig.DOGSTATSD_START_DELAY
@@ -109,13 +111,44 @@ class DDAgentStatsDClientTest extends DDSpecification {
109111
where:
110112
// spotless:off
111113
namespace | constantTags | expectedMetricName | expectedCheckName | expectedTags
112-
null | null | "test.metric" | "test.check" | "jmx_domain:java.nio,type:BufferPool"
113-
null | ["lang:java", "lang_version:1.8.0"] | "test.metric" | "test.check" | "jmx_domain:java.nio,type:BufferPool,lang:java,lang_version:1.8.0"
114-
"example" | null | "example.test.metric" | "example.test.check" | "jmx_domain:java.nio,type:BufferPool"
115-
"example" | ["lang:java", "lang_version:1.8.0"] | "example.test.metric" | "example.test.check" | "jmx_domain:java.nio,type:BufferPool,lang:java,lang_version:1.8.0"
114+
null | null | "test.metric" | "test.check" | "jmx_domain:java.nio,type:BufferPool,${ProcessTags.getTagsForSerialization().toString()}"
115+
null | ["lang:java", "lang_version:1.8.0"] | "test.metric" | "test.check" | "jmx_domain:java.nio,type:BufferPool,lang:java,lang_version:1.8.0,${ProcessTags.getTagsForSerialization().toString()}"
116+
"example" | null | "example.test.metric" | "example.test.check" | "jmx_domain:java.nio,type:BufferPool,${ProcessTags.getTagsForSerialization().toString()}"
117+
"example" | ["lang:java", "lang_version:1.8.0"] | "example.test.metric" | "example.test.check" | "jmx_domain:java.nio,type:BufferPool,lang:java,lang_version:1.8.0,${ProcessTags.getTagsForSerialization().toString()}"
116118
// spotless:on
117119
}
118120

121+
def "single statsd client without process tags"() {
122+
setup:
123+
injectSysConfig(DOGSTATSD_START_DELAY, '0')
124+
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "false")
125+
def server = new StatsDServer()
126+
server.start()
127+
ProcessTags.reset()
128+
129+
def client = statsDClientManager().statsDClient('127.0.0.1', server.socket.localPort, null, namespace, constantTags as String[], false)
130+
131+
String metricName = "test.metric"
132+
String[] tags = ["test:true"]
133+
134+
when:
135+
client.incrementCounter(metricName, tags)
136+
137+
then:
138+
server.waitForMessage().startsWith("$expectedMetricName:1|c|#$expectedTags")
139+
140+
cleanup:
141+
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "true")
142+
ProcessTags.reset()
143+
client.close()
144+
server.close()
145+
146+
where:
147+
namespace | constantTags | expectedMetricName | expectedTags
148+
null | null | "test.metric" | "test:true"
149+
null | ["lang:java", "lang_version:1.8.0"] | "test.metric" | "test:true,lang:java,lang_version:1.8.0"
150+
}
151+
119152
def "single statsd client with event"() {
120153
setup:
121154
injectSysConfig(DOGSTATSD_START_DELAY, '0')

components/environment/src/main/java/datadog/environment/JavaVirtualMachine.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ public static boolean isOracleJDK8() {
9393
&& !runtime.name.contains("OpenJDK");
9494
}
9595

96+
public static boolean isHotspot() {
97+
String prop = SystemProperties.getOrDefault("java.vm.name", "");
98+
if (prop.isEmpty()) {
99+
return false;
100+
}
101+
return prop.contains("OpenJDK")
102+
|| prop.contains("HotSpot")
103+
|| prop.contains("GraalVM")
104+
|| prop.contains("Dynamic Code Evolution");
105+
}
106+
96107
public static boolean isJ9() {
97108
return SystemProperties.getOrDefault("java.vm.name", "").contains("J9");
98109
}

0 commit comments

Comments
 (0)