Skip to content

Commit c4f244c

Browse files
authored
Merge branch 'master' into baptiste.foy/FA/fix-null-value
2 parents 0c12439 + d8b9ae8 commit c4f244c

File tree

65 files changed

+743
-243
lines changed

Some content is hidden

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

65 files changed

+743
-243
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()) {

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/outline/TypeOutline.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import net.bytebuddy.description.method.MethodList;
1414
import net.bytebuddy.description.type.TypeDescription;
1515
import net.bytebuddy.description.type.TypeList;
16+
import net.bytebuddy.jar.asm.Opcodes;
1617

1718
/** Provides an outline of a type; i.e. the named elements making up its structure. */
1819
final class TypeOutline extends WithName {
@@ -89,6 +90,30 @@ public int getModifiers() {
8990
return modifiers;
9091
}
9192

93+
@Override
94+
public boolean isAbstract() {
95+
return matchesMask(Opcodes.ACC_ABSTRACT);
96+
}
97+
98+
@Override
99+
public boolean isEnum() {
100+
return matchesMask(Opcodes.ACC_ENUM);
101+
}
102+
103+
@Override
104+
public boolean isInterface() {
105+
return matchesMask(Opcodes.ACC_INTERFACE);
106+
}
107+
108+
@Override
109+
public boolean isAnnotation() {
110+
return matchesMask(Opcodes.ACC_ANNOTATION);
111+
}
112+
113+
private boolean matchesMask(int mask) {
114+
return (this.getModifiers() & mask) == mask;
115+
}
116+
92117
@Override
93118
public ClassFileVersion getClassFileVersion() {
94119
return ClassFileVersion.ofMinorMajor(classFileVersion);

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/bytebuddy/outline/OutlineTypeParserTest.groovy

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import spock.lang.Specification
55

66
class OutlineTypeParserTest extends Specification {
77

8-
void 'test anonymous classes are detected'() {
8+
void 'test modifiers are correct and anonymous classes are detected'() {
99
setup:
1010
final parser = new OutlineTypeParser()
1111
final locator = ClassFileLocators.classFileLocator(Thread.currentThread().contextClassLoader)
@@ -16,15 +16,23 @@ class OutlineTypeParserTest extends Specification {
1616

1717
then:
1818
outline.anonymousType == anonymous
19+
outline.interface == isinterface
20+
outline.abstract == isabstract
21+
outline.annotation == annotation
22+
outline.enum == isenum
1923

2024
where:
21-
clazz | anonymous
22-
'datadog.trace.agent.test.EnclosedClasses' | false
23-
'datadog.trace.agent.test.EnclosedClasses$Inner' | false
24-
'datadog.trace.agent.test.EnclosedClasses$InnerStatic' | false
25-
'datadog.trace.agent.test.EnclosedClasses$1' | true
26-
'datadog.trace.agent.test.EnclosedClasses$2' | true
27-
'datadog.trace.agent.test.EnclosedClasses$Inner$1' | true
28-
'datadog.trace.agent.test.EnclosedClasses$InnerStatic$1' | true
25+
clazz | anonymous | isinterface | isabstract | annotation | isenum
26+
'datadog.trace.agent.test.EnclosedClasses' | false | false | false | false | false
27+
'datadog.trace.agent.test.EnclosedClasses$Inner' | false | false | false | false | false
28+
'datadog.trace.agent.test.EnclosedClasses$InnerStatic' | false | false | false | false | false
29+
'datadog.trace.agent.test.EnclosedClasses$1' | true | false | false | false | false
30+
'datadog.trace.agent.test.EnclosedClasses$2' | true | false | false | false | false
31+
'datadog.trace.agent.test.EnclosedClasses$Inner$1' | true | false | false | false | false
32+
'datadog.trace.agent.test.EnclosedClasses$InnerStatic$1' | true | false | false | false | false
33+
'datadog.trace.agent.test.EnclosedClasses$Interface' | false | true | true | false | false
34+
'datadog.trace.agent.test.EnclosedClasses$Abstract' | false | false | true | false | false
35+
'datadog.trace.agent.test.EnclosedClasses$Annotation' | false | true | true | true | false
36+
'datadog.trace.agent.test.EnclosedClasses$Enum' | false | false | false | false | true
2937
}
3038
}

dd-java-agent/agent-tooling/src/test/java/datadog/trace/agent/test/EnclosedClasses.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ public String get() {
4848
}.get();
4949
}
5050
}
51+
52+
public interface Interface {}
53+
54+
public abstract static class Abstract {}
55+
56+
public @interface Annotation {}
57+
58+
public enum Enum {}
5159
}

dd-java-agent/instrumentation/glassfish/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ dependencies {
2020
testImplementation libs.guava
2121
testImplementation group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.0'
2222
testRuntimeOnly project(':dd-java-agent:instrumentation:servlet:request-3')
23-
testRuntimeOnly project(':dd-java-agent:instrumentation:grizzly-2')
24-
testRuntimeOnly project(':dd-java-agent:instrumentation:grizzly-http-2.3.20')
23+
testRuntimeOnly project(':dd-java-agent:instrumentation:grizzly:grizzly-2.0')
24+
testRuntimeOnly project(':dd-java-agent:instrumentation:grizzly:grizzly-http-2.3.20')
2525

2626
latestDepTestImplementation group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '5+'
2727
}

dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/HttpServerFilterInstrumentation.java

Lines changed: 0 additions & 55 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)