Skip to content

Commit ff2aa24

Browse files
Merge remote-tracking branch 'origin/vzakharov/websockets_netty' into vzakharov/websockets_netty
2 parents 070b544 + aefad09 commit ff2aa24

File tree

145 files changed

+1157
-457
lines changed

Some content is hidden

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

145 files changed

+1157
-457
lines changed

.circleci/config.continue.yml.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
3636
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"
3737
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"
3838

39-
default_system_tests_commit: &default_system_tests_commit 2799fa982318da14c9d3e5f722abdc670d2802c3
39+
default_system_tests_commit: &default_system_tests_commit 761b9e7a82ffb136c4653a4d1623d120d67b005b
4040

4141
parameters:
4242
nightly:
@@ -932,7 +932,7 @@ jobs:
932932
command: |
933933
cd system-tests
934934
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh INTEGRATIONS
935-
935+
936936
- run:
937937
name: Run IDM Crossed Tracing Libraries propagation tests for messaging
938938
environment:
@@ -975,7 +975,7 @@ jobs:
975975
no_output_timeout: 5m
976976
command: |
977977
cd system-tests
978-
export DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
978+
export DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
979979
./run.sh DEBUGGER_SCENARIOS
980980
981981
- run:

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

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

3-
import static datadog.trace.api.ConfigDefaults.DEFAULT_DOGSTATSD_PORT;
43
import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.LOGGING_WRITER_TYPE;
54

65
import datadog.trace.api.Config;
@@ -22,7 +21,8 @@ public static StatsDClientManager statsDClientManager() {
2221
return INSTANCE;
2322
}
2423

25-
private static final AtomicInteger defaultStatsDPort = new AtomicInteger(DEFAULT_DOGSTATSD_PORT);
24+
private static final AtomicInteger defaultStatsDPort =
25+
new AtomicInteger(Config.get().getDogsStatsDPort());
2626

2727
public static void setDefaultStatsDPort(final int newPort) {
2828
if (newPort > 0 && defaultStatsDPort.getAndSet(newPort) != newPort) {

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static datadog.trace.api.ConfigDefaults.DEFAULT_STARTUP_LOGS_ENABLED;
44
import static datadog.trace.api.Platform.isJavaVersionAtLeast;
55
import static datadog.trace.api.Platform.isOracleJDK8;
6+
import static datadog.trace.api.telemetry.LogCollector.SEND_TELEMETRY;
67
import static datadog.trace.bootstrap.Library.WILDFLY;
78
import static datadog.trace.bootstrap.Library.detectLibraries;
89
import static datadog.trace.util.AgentThreadFactory.AgentThread.JMX_STARTUP;
@@ -44,6 +45,7 @@
4445
import datadog.trace.util.AgentTaskScheduler;
4546
import datadog.trace.util.AgentThreadFactory.AgentThread;
4647
import datadog.trace.util.throwable.FatalAgentMisconfigurationError;
48+
import de.thetaphi.forbiddenapis.SuppressForbidden;
4749
import java.lang.instrument.Instrumentation;
4850
import java.lang.reflect.InvocationTargetException;
4951
import java.lang.reflect.Method;
@@ -291,6 +293,8 @@ public static void start(
291293
codeOriginEnabled = isFeatureEnabled(AgentFeature.CODE_ORIGIN);
292294
agentlessLogSubmissionEnabled = isFeatureEnabled(AgentFeature.AGENTLESS_LOG_SUBMISSION);
293295

296+
patchJPSAccess(inst);
297+
294298
if (profilingEnabled) {
295299
if (!isOracleJDK8()) {
296300
// Profiling agent startup code is written in a way to allow `startProfilingAgent` be called
@@ -420,6 +424,23 @@ private static void injectAgentArgsConfig(String agentArgs) {
420424
}
421425
}
422426

427+
@SuppressForbidden
428+
public static void patchJPSAccess(Instrumentation inst) {
429+
if (Platform.isJavaVersionAtLeast(9)) {
430+
// Unclear if supported for J9, may need to revisit
431+
try {
432+
Class.forName("datadog.trace.util.JPMSJPSAccess")
433+
.getMethod("patchModuleAccess", Instrumentation.class)
434+
.invoke(null, inst);
435+
} catch (Exception e) {
436+
log.debug(
437+
SEND_TELEMETRY,
438+
"Failed to patch module access for jvmstat and Java version "
439+
+ Platform.getRuntimeVersion());
440+
}
441+
}
442+
}
443+
423444
public static void shutdown(final boolean sync) {
424445
StaticEventLogger.end("Agent");
425446
StaticEventLogger.stop();

dd-java-agent/agent-bootstrap/src/main/java11/datadog/trace/bootstrap/instrumentation/jfr/exceptions/ExceptionProfiling.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package datadog.trace.bootstrap.instrumentation.jfr.exceptions;
22

33
import datadog.trace.api.Config;
4+
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
45

56
/**
67
* JVM-wide singleton exception profiling service. Uses {@linkplain Config} class to configure
@@ -13,6 +14,24 @@ private static final class Holder {
1314
static final ExceptionProfiling INSTANCE = new ExceptionProfiling(Config.get());
1415
}
1516

17+
/**
18+
* Support for excluding certain exception types because they are used for control flow or leak
19+
* detection.
20+
*/
21+
public static final class Exclusion {
22+
public static void enter() {
23+
CallDepthThreadLocalMap.incrementCallDepth(Exclusion.class);
24+
}
25+
26+
public static void exit() {
27+
CallDepthThreadLocalMap.decrementCallDepth(Exclusion.class);
28+
}
29+
30+
public static boolean isEffective() {
31+
return CallDepthThreadLocalMap.getCallDepth(Exclusion.class) > 0;
32+
}
33+
}
34+
1635
/**
1736
* Get a pre-configured shared instance.
1837
*

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilitySystem.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import datadog.trace.api.civisibility.telemetry.NoOpMetricCollector;
1616
import datadog.trace.api.git.GitInfoProvider;
1717
import datadog.trace.bootstrap.ContextStore;
18+
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
1819
import datadog.trace.civisibility.config.ExecutionSettings;
1920
import datadog.trace.civisibility.config.JvmInfo;
2021
import datadog.trace.civisibility.coverage.file.instrumentation.CoverageClassTransformer;
@@ -41,6 +42,7 @@
4142
import java.nio.file.Path;
4243
import java.nio.file.Paths;
4344
import java.util.Collection;
45+
import java.util.concurrent.CopyOnWriteArrayList;
4446
import java.util.function.Predicate;
4547
import javax.annotation.Nullable;
4648
import org.slf4j.Logger;
@@ -101,10 +103,13 @@ public static void start(Instrumentation inst, SharedCommunicationObjects sco) {
101103

102104
CiVisibilityCoverageServices.Child coverageServices =
103105
new CiVisibilityCoverageServices.Child(services, repoServices, executionSettings);
104-
InstrumentationBridge.registerTestEventsHandlerFactory(
105-
new TestEventsHandlerFactory(
106-
services, repoServices, coverageServices, executionSettings));
106+
TestEventsHandlerFactory testEventsHandlerFactory =
107+
new TestEventsHandlerFactory(services, repoServices, coverageServices, executionSettings);
108+
InstrumentationBridge.registerTestEventsHandlerFactory(testEventsHandlerFactory);
107109
CoveragePerTestBridge.registerCoverageStoreRegistry(coverageServices.coverageStoreFactory);
110+
111+
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
112+
tracerAPI.addShutdownListener(testEventsHandlerFactory::shutdown);
108113
} else {
109114
InstrumentationBridge.registerTestEventsHandlerFactory(new NoOpTestEventsHandler.Factory());
110115
}
@@ -147,6 +152,8 @@ private static final class TestEventsHandlerFactory implements TestEventsHandler
147152
private final CiVisibilityRepoServices repoServices;
148153
private final TestFrameworkSession.Factory sessionFactory;
149154

155+
private final Collection<TestEventsHandler<?, ?>> handlers = new CopyOnWriteArrayList<>();
156+
150157
private TestEventsHandlerFactory(
151158
CiVisibilityServices services,
152159
CiVisibilityRepoServices repoServices,
@@ -174,12 +181,21 @@ public <SuiteKey, TestKey> TestEventsHandler<SuiteKey, TestKey> create(
174181
TestFrameworkSession testSession =
175182
sessionFactory.startSession(repoServices.moduleName, component, null, capabilities);
176183
TestFrameworkModule testModule = testSession.testModuleStart(repoServices.moduleName, null);
177-
return new TestEventsHandlerImpl<>(
178-
services.metricCollector,
179-
testSession,
180-
testModule,
181-
suiteStore != null ? suiteStore : new ConcurrentHashMapContextStore<>(),
182-
testStore != null ? testStore : new ConcurrentHashMapContextStore<>());
184+
TestEventsHandlerImpl<SuiteKey, TestKey> handler =
185+
new TestEventsHandlerImpl<>(
186+
services.metricCollector,
187+
testSession,
188+
testModule,
189+
suiteStore != null ? suiteStore : new ConcurrentHashMapContextStore<>(),
190+
testStore != null ? testStore : new ConcurrentHashMapContextStore<>());
191+
handlers.add(handler);
192+
return handler;
193+
}
194+
195+
public void shutdown() {
196+
for (TestEventsHandler<?, ?> handler : handlers) {
197+
handler.close();
198+
}
183199
}
184200
}
185201

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestFrameworkModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ TestSuiteImpl testSuiteStart(
2828
*/
2929
boolean isNew(@Nonnull TestIdentifier test);
3030

31-
boolean isFlaky(@Nonnull TestIdentifier test);
32-
3331
boolean isModified(@Nonnull TestSourceData testSourceData);
3432

3533
boolean isQuarantined(TestIdentifier test);

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ public boolean isNew(@Nonnull TestIdentifier test) {
9898
return executionStrategy.isNew(test);
9999
}
100100

101-
@Override
102-
public boolean isFlaky(@Nonnull TestIdentifier test) {
103-
return executionStrategy.isFlaky(test);
104-
}
105-
106101
@Override
107102
public boolean isModified(@Nonnull TestSourceData testSourceData) {
108103
return executionStrategy.isModified(testSourceData);

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ public boolean isNew(@Nonnull TestIdentifier test) {
8484
return executionStrategy.isNew(test);
8585
}
8686

87-
@Override
88-
public boolean isFlaky(@Nonnull TestIdentifier test) {
89-
return executionStrategy.isFlaky(test);
90-
}
91-
9287
@Override
9388
public boolean isModified(@Nonnull TestSourceData testSourceData) {
9489
return executionStrategy.isModified(testSourceData);

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,6 @@ public TestExecutionPolicy executionPolicy(
105105
return Regular.INSTANCE;
106106
}
107107

108-
@Override
109-
public boolean isNew(@Nonnull TestIdentifier test) {
110-
return false;
111-
}
112-
113-
@Override
114-
public boolean isFlaky(@Nonnull TestIdentifier test) {
115-
return false;
116-
}
117-
118108
@Override
119109
public int executionPriority(
120110
@Nullable TestIdentifier test, @Nonnull TestSourceData testSourceData) {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,6 @@ public int executionPriority(@Nullable TestIdentifier test, @Nonnull TestSourceD
305305
return testModule.executionPriority(test, testSource);
306306
}
307307

308-
@Override
309-
public boolean isNew(@Nonnull TestIdentifier test) {
310-
return testModule.isNew(test);
311-
}
312-
313-
@Override
314-
public boolean isFlaky(@Nonnull TestIdentifier test) {
315-
return testModule.isFlaky(test);
316-
}
317-
318308
@Nullable
319309
@Override
320310
public SkipReason skipReason(TestIdentifier test) {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/test/ExecutionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean isNew(@Nonnull TestIdentifier test) {
6060
&& !executionSettings.isKnown(test.toFQN());
6161
}
6262

63-
public boolean isFlaky(@Nonnull TestIdentifier test) {
63+
private boolean isFlaky(@Nonnull TestIdentifier test) {
6464
return executionSettings.isFlaky(test.toFQN());
6565
}
6666

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void initialize(String onOutOfMemoryVal) {
4343
Path scriptPath = getOOMEScripPath(onOutOfMemoryVal);
4444
if (scriptPath == null) {
4545
LOG.debug(
46-
"OOME notifier script value ({}) does not follow the expected format: <path>/dd_ome_notifier.(sh|bat) %p. OOME tracking is disabled.",
46+
"OOME notifier script value ({}) does not follow the expected format: <path>/dd_oome_notifier.(sh|bat) %p. OOME tracking is disabled.",
4747
onOutOfMemoryVal);
4848
return;
4949
}
Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,64 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

3-
set +e # Disable exit on error
3+
# Disable exit on error
4+
set +e
45

56
# Check if PID is provided
67
if [ -z "$1" ]; then
78
echo "Error: No PID provided"
89
exit 1
910
fi
10-
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # Get the directory of the script
11+
12+
# Get the directory of the script
13+
HERE=$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)
1114
PID=$1
1215

13-
# Get the base name of the script
14-
scriptName=$(basename "$0" .sh)
16+
# Get the base name of the script (without .sh)
17+
scriptName=$(basename "$0")
18+
scriptName=${scriptName%.sh}
19+
1520
configFile="${HERE}/${scriptName}_pid${PID}.cfg"
1621
if [ ! -f "$configFile" ]; then
1722
echo "Error: Configuration file not found: $configFile"
1823
exit 1
1924
fi
2025

26+
# Initialize config values
27+
config_agent=""
28+
config_tags=""
29+
config_java_home=""
30+
2131
# Read the configuration file
22-
# The expected contents are:
23-
# - agent: Path to the agent jar
24-
# - tags: Comma-separated list of tags to be sent with the OOME event; key:value pairs are supported
2532
while IFS="=" read -r key value; do
26-
declare "config_$key"="$value"
33+
case "$key" in
34+
agent) config_agent=$value ;;
35+
tags) config_tags=$value ;;
36+
java_home) config_java_home=$value ;;
37+
esac
2738
done < "$configFile"
2839

2940
# Exiting early if configuration is missing
30-
if [ -z "${config_agent}" ] || [ -z "${config_tags}" ] || [ -z "${config_java_home}" ]; then
41+
if [ -z "$config_agent" ] || [ -z "$config_tags" ] || [ -z "$config_java_home" ]; then
3142
echo "Error: Missing configuration"
3243
exit 1
3344
fi
3445

3546
# Debug: Print the loaded values (Optional)
36-
echo "Agent Jar: ${config_agent}"
37-
echo "Tags: ${config_tags}"
38-
echo "JAVA_HOME: ${config_java_home}"
47+
echo "Agent Jar: $config_agent"
48+
echo "Tags: $config_tags"
49+
echo "JAVA_HOME: $config_java_home"
3950
echo "PID: $PID"
4051

4152
# Execute the Java command with the loaded values
42-
"${config_java_home}/bin/java" -Ddd.dogstatsd.start-delay=0 -jar "${config_agent}" sendOomeEvent "${config_tags}"
53+
"$config_java_home/bin/java" -Ddd.dogstatsd.start-delay=0 -jar "$config_agent" sendOomeEvent "$config_tags"
4354
RC=$?
44-
rm -f "${configFile}" # Remove the configuration file
4555

46-
if [ $RC -eq 0 ]; then
56+
# Remove the configuration file
57+
rm -f "$configFile"
58+
59+
if [ "$RC" -eq 0 ]; then
4760
echo "OOME Event generated successfully"
4861
else
4962
echo "Error: Failed to generate OOME event"
50-
exit $RC
63+
exit "$RC"
5164
fi

0 commit comments

Comments
 (0)