Skip to content

Commit abac8af

Browse files
authored
Prevent using v1/input endpoint for snapshots (#9573)
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 33d6c0a commit abac8af

File tree

9 files changed

+15
-12
lines changed

9 files changed

+15
-12
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;

communication/src/test/groovy/datadog/communication/ddagent/DDAgentFeaturesDiscoveryTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
440440
1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_WITH_TELEMETRY_PROXY_RESPONSE) }
441441
features.supportsTelemetryProxy()
442442
features.supportsDebugger()
443-
features.getDebuggerSnapshotEndpoint() == "debugger/v1/input"
444-
!features.supportsDebuggerDiagnostics()
443+
features.getDebuggerSnapshotEndpoint() == "debugger/v1/diagnostics"
444+
features.supportsDebuggerDiagnostics()
445445
0 * _
446446
}
447447

communication/src/test/resources/agent-features/agent-info-with-telemetry-proxy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"/evp_proxy/v1/",
1616
"/evp_proxy/v2/",
1717
"/debugger/v1/input",
18+
"/debugger/v1/diagnostics",
1819
"/v0.7/config"
1920
],
2021
"feature_flags": [

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 =

dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/InstrumentationSpecification.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import static datadog.communication.http.OkHttpUtils.buildHttpClient
8080
import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_HOST
8181
import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_TIMEOUT
8282
import static datadog.trace.api.ConfigDefaults.DEFAULT_TRACE_AGENT_PORT
83+
import static datadog.trace.api.config.DebuggerConfig.DYNAMIC_INSTRUMENTATION_SNAPSHOT_URL
8384
import static datadog.trace.api.config.DebuggerConfig.DYNAMIC_INSTRUMENTATION_VERIFY_BYTECODE
8485
import static datadog.trace.api.config.TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED
8586
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.closePrevious
@@ -308,6 +309,7 @@ abstract class InstrumentationSpecification extends DDSpecification implements A
308309
def codeOriginSetup() {
309310
injectSysConfig(CODE_ORIGIN_FOR_SPANS_ENABLED, "true", true)
310311
injectSysConfig(DYNAMIC_INSTRUMENTATION_VERIFY_BYTECODE, "false", true)
312+
injectSysConfig(DYNAMIC_INSTRUMENTATION_SNAPSHOT_URL, "http://localhost:1234/debugger/v1/input", true)
311313
rebuildConfig()
312314

313315
def configuration = Configuration.builder()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4184,7 +4184,7 @@ public String getFinalDebuggerSnapshotUrl() {
41844184
} else if (isCiVisibilityAgentlessEnabled()) {
41854185
return Intake.LOGS.getAgentlessUrl(this) + "logs";
41864186
} else {
4187-
return getFinalDebuggerBaseUrl() + "/debugger/v1/input";
4187+
throw new IllegalArgumentException("Cannot find snapshot endpoint on datadog agent");
41884188
}
41894189
}
41904190

internal-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ class ConfigTest extends DDSpecification {
267267
prop.setProperty(DYNAMIC_INSTRUMENTATION_VERIFY_BYTECODE, "true")
268268
prop.setProperty(DYNAMIC_INSTRUMENTATION_INSTRUMENT_THE_WORLD, "method")
269269
prop.setProperty(DYNAMIC_INSTRUMENTATION_EXCLUDE_FILES, "exclude file")
270+
prop.setProperty(DYNAMIC_INSTRUMENTATION_SNAPSHOT_URL, "http://somehost:123/debugger/v1/input")
270271
prop.setProperty(EXCEPTION_REPLAY_ENABLED, "true")
271272
prop.setProperty(TRACE_X_DATADOG_TAGS_MAX_LENGTH, "128")
272273
prop.setProperty(JDK_SOCKET_ENABLED, "false")
@@ -2785,7 +2786,6 @@ class ConfigTest extends DDSpecification {
27852786
Config config = Config.get(prop)
27862787

27872788
then:
2788-
config.finalDebuggerSnapshotUrl == "http://localhost:8126/debugger/v1/input"
27892789
config.finalDebuggerSymDBUrl == "http://localhost:8126/symdb/v1/input"
27902790
}
27912791

0 commit comments

Comments
 (0)