Skip to content

Commit d8b9ae8

Browse files
authored
add support debugger/v2/input endpoint (#9406)
1 parent 87351d8 commit d8b9ae8

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
6060

6161
public static final String DATADOG_AGENT_STATE = "Datadog-Agent-State";
6262

63-
public static final String DEBUGGER_ENDPOINT = "debugger/v1/input";
63+
public static final String DEBUGGER_ENDPOINT_V1 = "debugger/v1/input";
64+
public static final String DEBUGGER_ENDPOINT_V2 = "debugger/v2/input";
6465
public static final String DEBUGGER_DIAGNOSTICS_ENDPOINT = "debugger/v1/diagnostics";
6566

6667
public static final String TELEMETRY_PROXY_ENDPOINT = "telemetry/proxy/";
@@ -276,8 +277,15 @@ private boolean processInfoResponse(String response) {
276277
}
277278
}
278279

279-
if (containsEndpoint(endpoints, DEBUGGER_ENDPOINT)) {
280-
debuggerEndpoint = DEBUGGER_ENDPOINT;
280+
// both debugger endpoint v2 and diagnostics endpoint are forwarding events to the DEBUGGER
281+
// intake
282+
// because older agents support diagnostics, we fallback to it before falling back to v1
283+
if (containsEndpoint(endpoints, DEBUGGER_ENDPOINT_V2)) {
284+
debuggerEndpoint = DEBUGGER_ENDPOINT_V2;
285+
} else if (containsEndpoint(endpoints, DEBUGGER_DIAGNOSTICS_ENDPOINT)) {
286+
debuggerEndpoint = DEBUGGER_DIAGNOSTICS_ENDPOINT;
287+
} else if (containsEndpoint(endpoints, DEBUGGER_ENDPOINT_V1)) {
288+
debuggerEndpoint = DEBUGGER_ENDPOINT_V1;
281289
}
282290
if (containsEndpoint(endpoints, DEBUGGER_DIAGNOSTICS_ENDPOINT)) {
283291
debuggerDiagnosticsEndpoint = DEBUGGER_DIAGNOSTICS_ENDPOINT;
@@ -363,6 +371,10 @@ public boolean supportsDebugger() {
363371
return debuggerEndpoint != null;
364372
}
365373

374+
public String getDebuggerEndpoint() {
375+
return debuggerEndpoint;
376+
}
377+
366378
public boolean supportsDebuggerDiagnostics() {
367379
return debuggerDiagnosticsEndpoint != null;
368380
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
6666
features.state() == INFO_STATE
6767
features.getConfigEndpoint() == V7_CONFIG_ENDPOINT
6868
features.supportsDebugger()
69+
features.getDebuggerEndpoint() == "debugger/v2/input"
6970
features.supportsDebuggerDiagnostics()
7071
features.supportsEvpProxy()
7172
features.supportsContentEncodingHeadersWithEvpProxy()
@@ -412,6 +413,9 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
412413
then:
413414
1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_WITH_TELEMETRY_PROXY_RESPONSE) }
414415
features.supportsTelemetryProxy()
416+
features.supportsDebugger()
417+
features.getDebuggerEndpoint() == "debugger/v1/input"
418+
!features.supportsDebuggerDiagnostics()
415419
0 * _
416420
}
417421

@@ -428,6 +432,10 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
428432
features.supportsEvpProxy()
429433
features.getEvpProxyEndpoint() == "evp_proxy/v2/" // v3 is advertised, but the tracer should ignore it
430434
!features.supportsContentEncodingHeadersWithEvpProxy()
435+
features.supportsDebugger()
436+
features.getDebuggerEndpoint() == "debugger/v1/diagnostics"
437+
features.supportsDebuggerDiagnostics()
438+
0 * _
431439
}
432440

433441
def "test parse /info response with peer tag back propagation"() {

communication/src/test/resources/agent-features/agent-info.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"/evp_proxy/v3/",
1717
"/evp_proxy/v4/",
1818
"/debugger/v1/input",
19+
"/debugger/v2/input",
1920
"/debugger/v1/diagnostics",
2021
"/v0.7/config"
2122
],

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private static void commonInit(Config config) {
117117
ProbeStatusSink probeStatusSink =
118118
new ProbeStatusSink(
119119
config, diagnosticEndpoint, ddAgentFeaturesDiscovery.supportsDebuggerDiagnostics());
120-
DebuggerSink debuggerSink = createDebuggerSink(config, probeStatusSink);
120+
DebuggerSink debuggerSink =
121+
createDebuggerSink(config, ddAgentFeaturesDiscovery, probeStatusSink);
121122
debuggerSink.start();
122123
configurationUpdater =
123124
new ConfigurationUpdater(
@@ -273,14 +274,19 @@ public static void stopDistributedDebugger() {
273274
LOGGER.info("Sopping Distributed Debugger");
274275
}
275276

276-
private static DebuggerSink createDebuggerSink(Config config, ProbeStatusSink probeStatusSink) {
277+
private static DebuggerSink createDebuggerSink(
278+
Config config,
279+
DDAgentFeaturesDiscovery ddAgentFeaturesDiscovery,
280+
ProbeStatusSink probeStatusSink) {
277281
String tags = getDefaultTagsMergedWithGlobalTags(config);
278282
SnapshotSink snapshotSink =
279283
new SnapshotSink(
280284
config,
281285
tags,
282286
new BatchUploader(
283-
config, config.getFinalDebuggerSnapshotUrl(), SnapshotSink.RETRY_POLICY));
287+
config,
288+
getDebuggerEndpoint(config, ddAgentFeaturesDiscovery),
289+
SnapshotSink.RETRY_POLICY));
284290
SymbolSink symbolSink = new SymbolSink(config);
285291
return new DebuggerSink(
286292
config,
@@ -314,6 +320,16 @@ public static String getDefaultTagsMergedWithGlobalTags(Config config) {
314320
return debuggerTags + "," + globalTags;
315321
}
316322

323+
private static String getDebuggerEndpoint(
324+
Config config, DDAgentFeaturesDiscovery ddAgentFeaturesDiscovery) {
325+
if (ddAgentFeaturesDiscovery.supportsDebugger()) {
326+
return ddAgentFeaturesDiscovery
327+
.buildUrl(ddAgentFeaturesDiscovery.getDebuggerEndpoint())
328+
.toString();
329+
}
330+
return config.getFinalDebuggerSnapshotUrl();
331+
}
332+
317333
private static String getDiagnosticEndpoint(
318334
Config config, DDAgentFeaturesDiscovery ddAgentFeaturesDiscovery) {
319335
if (ddAgentFeaturesDiscovery.supportsDebuggerDiagnostics()) {

0 commit comments

Comments
 (0)