Skip to content

Commit ae31670

Browse files
feat: headless and agentless changes
1 parent c4c84d6 commit ae31670

File tree

6 files changed

+24
-37
lines changed

6 files changed

+24
-37
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ public void execute() {
577577
}
578578

579579
maybeStartAppSec(scoClass, sco);
580+
// start before debugger to enable Failed Test Replay correctly
580581
maybeStartCiVisibility(instrumentation, scoClass, sco);
581582
// start debugger before remote config to subscribe to it before starting to poll
582583
maybeStartDebugger(instrumentation, scoClass, sco);
@@ -1153,10 +1154,6 @@ && isExplicitlyDisabled(TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED
11531154
&& isExplicitlyDisabled(DebuggerConfig.DISTRIBUTED_DEBUGGER_ENABLED)) {
11541155
return;
11551156
}
1156-
if (!remoteConfigEnabled) {
1157-
log.warn("Cannot enable Dynamic Instrumentation because Remote Configuration is not enabled");
1158-
return;
1159-
}
11601157
startDebuggerAgent(inst, scoClass, sco);
11611158
}
11621159

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static void start(Instrumentation inst, SharedCommunicationObjects sco) {
102102
}
103103

104104
if (executionSettings.isFailedTestReplayEnabled()) {
105-
// TODO
105+
config.setCiVisibilityFailedTestReplayEnabled(true);
106106
}
107107

108108
CiVisibilityCoverageServices.Child coverageServices =

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,6 @@ private Map<String, String> getPropertiesPropagatedToChildProcess(
193193
propagatedSystemProperties.put(
194194
Strings.propertyNameToSystemPropertyName(DebuggerConfig.EXCEPTION_REPLAY_ENABLED),
195195
"true");
196-
propagatedSystemProperties.put(
197-
Strings.propertyNameToSystemPropertyName(RemoteConfigConfig.REMOTE_CONFIGURATION_ENABLED),
198-
"true");
199196
}
200197

201198
// explicitly disable build instrumentation in child processes,

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/exception/DefaultExceptionDebugger.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public DefaultExceptionDebugger(
7474

7575
@Override
7676
public void handleException(Throwable t, AgentSpan span) {
77-
if (t instanceof Error && !Config.get().isCiVisibilityEnabled()) {
77+
// CIVIS Failed Test Replay acts on errors
78+
if (t instanceof Error && !Config.get().isCiVisibilityFailedTestReplayEnabled()) {
7879
if (LOGGER.isDebugEnabled()) {
7980
LOGGER.debug("Skip handling error: {}", t.toString());
8081
}
@@ -98,7 +99,6 @@ public void handleException(Throwable t, AgentSpan span) {
9899
if (exceptionProbeManager.isAlreadyInstrumented(fingerprint)) {
99100
ThrowableState state = exceptionProbeManager.getStateByThrowable(innerMostException);
100101
if (state == null) {
101-
LOGGER.info("Unable to find state for throwable: {}", innerMostException.toString());
102102
LOGGER.debug("Unable to find state for throwable: {}", innerMostException.toString());
103103
return;
104104
}
@@ -114,8 +114,9 @@ public void handleException(Throwable t, AgentSpan span) {
114114
exceptionProbeManager.createProbesForException(
115115
throwable.getStackTrace(), chainedExceptionIdx);
116116
if (creationResult.probesCreated > 0) {
117-
LOGGER.info("Creating probes for: {}", t.getMessage());
118-
if (Config.get().isCiVisibilityEnabled()) {
117+
if (Config.get().isCiVisibilityFailedTestReplayEnabled()) {
118+
// Assume Exception Replay is working under Failed Test Replay logic,
119+
// instrumentation applied sync for immediate test retries
119120
applyExceptionConfiguration(fingerprint);
120121
} else {
121122
AgentTaskScheduler.INSTANCE.execute(() -> applyExceptionConfiguration(fingerprint));
@@ -158,7 +159,6 @@ private static void processSnapshotsAndSetTags(
158159
}
159160
});
160161
}
161-
LOGGER.info("Processing exception snapshot for: {}", t.getMessage());
162162
boolean snapshotAssigned = false;
163163
List<Snapshot> snapshots = state.getSnapshots();
164164
int maxSnapshotSize = Math.min(snapshots.size(), maxCapturedFrames);
@@ -197,7 +197,6 @@ private static void processSnapshotsAndSetTags(
197197
DebuggerAgent.getSink().addSnapshot(snapshot);
198198
}
199199
snapshotAssigned = true;
200-
LOGGER.info("Capture for {}: {}", t.getMessage(), snapshots.get(i).getVariables());
201200
}
202201
if (snapshotAssigned) {
203202
state.markAsSnapshotSent();

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/sink/Snapshot.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.util.List;
1313
import java.util.Map;
1414
import java.util.Objects;
15-
import java.util.stream.Collectors;
1615

1716
/** Data class representing all data collected at a probe location */
1817
public class Snapshot {
@@ -162,18 +161,6 @@ public List<EvaluationError> getEvaluationErrors() {
162161
return evaluationErrors;
163162
}
164163

165-
public String getVariables() {
166-
String variables = "";
167-
CapturedContext returnContext = captures.getReturn();
168-
if (returnContext != null) {
169-
Map<String, CapturedContext.CapturedValue> allVars = new HashMap<>();
170-
if (returnContext.getArguments() != null) allVars.putAll(returnContext.getArguments());
171-
if (returnContext.getLocals() != null) allVars.putAll(returnContext.getLocals());
172-
variables = allVars.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue().getStrValue()).collect(Collectors.joining(", "));
173-
}
174-
return variables;
175-
}
176-
177164
public void addEvaluationErrors(List<EvaluationError> errors) {
178165
if (errors == null || errors.isEmpty()) {
179166
return;

internal-api/src/main/java/datadog/trace/api/Config.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ public static String getHostName() {
10031003
private final String gitPullRequestBaseBranch;
10041004
private final String gitPullRequestBaseBranchSha;
10051005
private final String gitCommitHeadSha;
1006-
private final boolean ciVisibilityFailedTestReplayEnabled;
1006+
private boolean ciVisibilityFailedTestReplayEnabled;
10071007

10081008
private final boolean remoteConfigEnabled;
10091009
private final boolean remoteConfigIntegrityCheckEnabled;
@@ -3840,6 +3840,10 @@ public boolean isCiVisibilityFailedTestReplayEnabled() {
38403840
return ciVisibilityFailedTestReplayEnabled;
38413841
}
38423842

3843+
public void setCiVisibilityFailedTestReplayEnabled(boolean enabled) {
3844+
ciVisibilityFailedTestReplayEnabled = enabled;
3845+
}
3846+
38433847
public String getGitPullRequestBaseBranch() {
38443848
return gitPullRequestBaseBranch;
38453849
}
@@ -3961,7 +3965,7 @@ public boolean isSymbolDatabaseCompressed() {
39613965
}
39623966

39633967
public boolean isDebuggerExceptionEnabled() {
3964-
return debuggerExceptionEnabled;
3968+
return debuggerExceptionEnabled || ciVisibilityFailedTestReplayEnabled;
39653969
}
39663970

39673971
public int getDebuggerMaxExceptionPerSecond() {
@@ -4009,13 +4013,7 @@ public Set<String> getThirdPartyShadingIdentifiers() {
40094013
}
40104014

40114015
private String getFinalDebuggerBaseUrl() {
4012-
if (isCiVisibilityEnabled() && isCiVisibilityAgentlessEnabled()) {
4013-
String agentlessUrl = getCiVisibilityAgentlessUrl();
4014-
if (Strings.isNotBlank(agentlessUrl)) {
4015-
return agentlessUrl;
4016-
}
4017-
return "https://http-intake.logs." + getSite();
4018-
} else if (agentUrl.startsWith("unix:")) {
4016+
if (agentUrl.startsWith("unix:")) {
40194017
// provide placeholder agent URL, in practice we'll be tunnelling over UDS
40204018
return "http://" + agentHost + ":" + agentPort;
40214019
} else {
@@ -4024,7 +4022,16 @@ private String getFinalDebuggerBaseUrl() {
40244022
}
40254023

40264024
public String getFinalDebuggerSnapshotUrl() {
4027-
return getFinalDebuggerBaseUrl() + "/debugger/v1/input";
4025+
if (isCiVisibilityFailedTestReplayEnabled() && isCiVisibilityAgentlessEnabled()) {
4026+
// Used in Failed Test Replay agentless
4027+
String agentlessUrl = getCiVisibilityAgentlessUrl();
4028+
if (Strings.isBlank(agentlessUrl)) {
4029+
agentlessUrl = "https://http-intake.logs." + getSite();
4030+
}
4031+
return agentlessUrl + "/api/v2/logs";
4032+
} else {
4033+
return getFinalDebuggerBaseUrl() + "/debugger/v1/input";
4034+
}
40284035
}
40294036

40304037
public String getFinalDebuggerSymDBUrl() {

0 commit comments

Comments
 (0)