Skip to content

Commit 05744f0

Browse files
committed
Prevent using v1/input endpoint for snapshots
snapshots should always send to DEBUGGER track through v2/input or v1/diagnostics endpoints. v1/input is unredacted. v1/diagnostics endpoint was introduced since DD agent 7.49
1 parent abb87ab commit 05744f0

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,11 @@ private boolean processInfoResponse(State newState, String response) {
271271
newState.debuggerLogEndpoint = DEBUGGER_ENDPOINT_V1;
272272
}
273273
// both debugger v2 and diagnostics endpoints are forwarding events to the DEBUGGER intake
274-
// because older agents support diagnostics, we fall back to it before falling back to v1
274+
// because older agents support diagnostics from DD agent 7.49
275275
if (containsEndpoint(endpoints, DEBUGGER_ENDPOINT_V2)) {
276276
newState.debuggerSnapshotEndpoint = DEBUGGER_ENDPOINT_V2;
277277
} else if (containsEndpoint(endpoints, DEBUGGER_DIAGNOSTICS_ENDPOINT)) {
278278
newState.debuggerSnapshotEndpoint = DEBUGGER_DIAGNOSTICS_ENDPOINT;
279-
} else if (containsEndpoint(endpoints, DEBUGGER_ENDPOINT_V1)) {
280-
newState.debuggerSnapshotEndpoint = DEBUGGER_ENDPOINT_V1;
281279
}
282280
if (containsEndpoint(endpoints, DEBUGGER_DIAGNOSTICS_ENDPOINT)) {
283281
newState.debuggerDiagnosticsEndpoint = DEBUGGER_DIAGNOSTICS_ENDPOINT;

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerAgent.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,11 @@ private static String getLogEndpoint(
341341
private static String getSnapshotEndpoint(
342342
Config config, DDAgentFeaturesDiscovery ddAgentFeaturesDiscovery) {
343343
if (ddAgentFeaturesDiscovery.supportsDebugger()) {
344-
return ddAgentFeaturesDiscovery
345-
.buildUrl(ddAgentFeaturesDiscovery.getDebuggerSnapshotEndpoint())
346-
.toString();
344+
String debuggerSnapshotEndpoint = ddAgentFeaturesDiscovery.getDebuggerSnapshotEndpoint();
345+
if (debuggerSnapshotEndpoint == null) {
346+
throw new IllegalArgumentException("Cannot find snapshot endpoint on datadog agent");
347+
}
348+
return ddAgentFeaturesDiscovery.buildUrl(debuggerSnapshotEndpoint).toString();
347349
}
348350
return config.getFinalDebuggerSnapshotUrl();
349351
}

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturingTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public static Config getConfig() {
385385
setFieldInConfig(config, "dynamicInstrumentationClassFileDumpEnabled", true);
386386
setFieldInConfig(config, "dynamicInstrumentationVerifyByteCode", false);
387387
setFieldInConfig(config, "debuggerCodeOriginMaxUserFrames", 20);
388-
388+
setFieldInConfig(config, "dynamicInstrumentationSnapshotUrl", "http://localhost:8080");
389389
return config;
390390
}
391391

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/DebuggerAgentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void runEnabledWithDatadogAgent() throws InterruptedException, IOExceptio
101101
setFieldInConfig(Config.get(), "dynamicInstrumentationMaxPayloadSize", 4096L);
102102
setFieldInContainerInfo(ContainerInfo.get(), "containerId", "");
103103
String infoContent =
104-
"{\"endpoints\": [\"v0.4/traces\", \"debugger/v1/input\", \"v0.7/config\"] }";
104+
"{\"endpoints\": [\"v0.4/traces\", \"debugger/v1/input\", \"debugger/v1/diagnostics\", \"v0.7/config\"] }";
105105
datadogAgentServer.enqueue(new MockResponse().setResponseCode(200).setBody(infoContent));
106106
datadogAgentServer.enqueue(new MockResponse().setResponseCode(200).setBody(infoContent));
107107
try (BufferedReader reader =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4176,7 +4176,7 @@ public String getFinalDebuggerSnapshotUrl() {
41764176
} else if (isCiVisibilityAgentlessEnabled()) {
41774177
return Intake.LOGS.getAgentlessUrl(this) + "logs";
41784178
} else {
4179-
return getFinalDebuggerBaseUrl() + "/debugger/v1/input";
4179+
throw new IllegalArgumentException("Cannot find snapshot endpoint on datadog agent");
41804180
}
41814181
}
41824182

0 commit comments

Comments
 (0)