Skip to content

Commit 4fe3d47

Browse files
authored
Merge branch 'master' into INPLAT-614
2 parents fa08696 + ad6d6b9 commit 4fe3d47

File tree

40 files changed

+197
-64
lines changed

40 files changed

+197
-64
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ variables:
2828
GRADLE_VERSION: "8.14.3" # must match gradle-wrapper.properties
2929
MAVEN_REPOSITORY_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/maven-central/"
3030
GRADLE_PLUGIN_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/gradle-plugin-portal-proxy/"
31-
BUILDER_IMAGE_VERSION_PREFIX: "v25.06-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
31+
BUILDER_IMAGE_VERSION_PREFIX: "v25.07-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
3232
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
3333
DEFAULT_TEST_JVMS: /^(8|11|17|21|stable)$/
3434
PROFILE_TESTS:

.gitlab/upload_ciapp.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,20 @@ junit_upload() {
3535
./results
3636
}
3737

38+
# Upload code coverage results to Datadog
39+
coverage_upload() {
40+
DD_API_KEY=$1 \
41+
[email protected]:DataDog/dd-trace-java.git \
42+
datadog-ci coverage upload --ignored-paths=./test-published-dependencies .
43+
}
44+
3845
# Upload test results to production environment like all other CI jobs
3946
junit_upload "$DATADOG_API_KEY_PROD"
47+
junit_upload_status=$?
48+
49+
coverage_upload "$DATADOG_API_KEY_PROD"
50+
coverage_upload_status=$?
51+
52+
if [[ $junit_upload_status -ne 0 || $coverage_upload_status -ne 0 ]]; then
53+
exit 1
54+
fi

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package datadog.communication.ddagent;
22

33
import static datadog.communication.serialization.msgpack.MsgPackWriter.FIXARRAY;
4+
import static java.util.Collections.emptyList;
45
import static java.util.Collections.singletonList;
6+
import static java.util.Collections.unmodifiableList;
57

68
import com.squareup.moshi.JsonAdapter;
79
import com.squareup.moshi.Moshi;
@@ -86,6 +88,8 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
8688
private volatile String evpProxyEndpoint;
8789
private volatile String version;
8890
private volatile String telemetryProxyEndpoint;
91+
private volatile List<String> peerTags = emptyList();
92+
private volatile List<String> spanKindsToComputedStats = emptyList();
8993

9094
private long lastTimeDiscovered;
9195

@@ -119,6 +123,8 @@ private void reset() {
119123
version = null;
120124
lastTimeDiscovered = 0;
121125
telemetryProxyEndpoint = null;
126+
peerTags = emptyList();
127+
spanKindsToComputedStats = emptyList();
122128
}
123129

124130
/** Run feature discovery, unconditionally. */
@@ -287,6 +293,13 @@ private boolean processInfoResponse(String response) {
287293
null != canDrop
288294
&& ("true".equalsIgnoreCase(String.valueOf(canDrop))
289295
|| Boolean.TRUE.equals(canDrop));
296+
297+
Object peer_tags = map.get("peer_tags");
298+
peerTags = peer_tags == null ? emptyList() : unmodifiableList((List<String>) peer_tags);
299+
300+
Object span_kinds = map.get("span_kinds_stats_computed");
301+
spanKindsToComputedStats =
302+
span_kinds == null ? emptyList() : unmodifiableList((List<String>) span_kinds);
290303
}
291304
try {
292305
state = Strings.sha256(response);
@@ -344,6 +357,14 @@ public boolean supportsLongRunning() {
344357
return supportsLongRunning;
345358
}
346359

360+
public List<String> peerTags() {
361+
return peerTags;
362+
}
363+
364+
public List<String> spanKindsToComputedStats() {
365+
return spanKindsToComputedStats;
366+
}
367+
347368
public String getMetricsEndpoint() {
348369
return metricsEndpoint;
349370
}

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
3030

3131
static final String INFO_RESPONSE = loadJsonFile("agent-info.json")
3232
static final String INFO_STATE = Strings.sha256(INFO_RESPONSE)
33+
static final String INFO_WITH_PEER_TAG_BACK_PROPAGATION_RESPONSE = loadJsonFile("agent-info-with-peer-tag-back-propagation.json")
34+
static final String INFO_WITH_PEER_TAG_BACK_PROPAGATION_STATE = Strings.sha256(INFO_WITH_PEER_TAG_BACK_PROPAGATION_RESPONSE)
3335
static final String INFO_WITH_CLIENT_DROPPING_RESPONSE = loadJsonFile("agent-info-with-client-dropping.json")
3436
static final String INFO_WITH_CLIENT_DROPPING_STATE = Strings.sha256(INFO_WITH_CLIENT_DROPPING_RESPONSE)
3537
static final String INFO_WITHOUT_METRICS_RESPONSE = loadJsonFile("agent-info-without-metrics.json")
@@ -424,6 +426,46 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
424426
!features.supportsContentEncodingHeadersWithEvpProxy()
425427
}
426428

429+
def "test parse /info response with peer tag back propagation"() {
430+
setup:
431+
OkHttpClient client = Mock(OkHttpClient)
432+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
433+
434+
when: "/info available"
435+
features.discover()
436+
437+
then:
438+
1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_RESPONSE) }
439+
440+
when: "/info available with peer tag back propagation"
441+
features.discover()
442+
443+
then:
444+
1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_WITH_PEER_TAG_BACK_PROPAGATION_RESPONSE) }
445+
features.state() == INFO_WITH_PEER_TAG_BACK_PROPAGATION_STATE
446+
features.supportsDropping()
447+
features.peerTags().containsAll(
448+
"_dd.base_service",
449+
"active_record.db.vendor",
450+
"amqp.destination",
451+
"amqp.exchange",
452+
"amqp.queue",
453+
"grpc.host",
454+
"hostname",
455+
"http.host",
456+
"http.server_name",
457+
"streamname",
458+
"tablename",
459+
"topicname"
460+
)
461+
features.spanKindsToComputedStats().containsAll(
462+
"client",
463+
"consumer",
464+
"producer",
465+
"server"
466+
)
467+
}
468+
427469
def infoResponse(Request request, String json) {
428470
return Mock(Call) {
429471
it.execute() >> new Response.Builder()
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"version": "7.67.0",
3+
"git_commit": "bdf863ccc9",
4+
"endpoints": [
5+
"/v0.3/traces",
6+
"/v0.3/services",
7+
"/v0.4/traces",
8+
"/v0.4/services",
9+
"/v0.5/traces",
10+
"/v0.7/traces",
11+
"/profiling/v1/input",
12+
"/telemetry/proxy/",
13+
"/v0.6/stats",
14+
"/v0.1/pipeline_stats",
15+
"/openlineage/api/v1/lineage",
16+
"/evp_proxy/v1/",
17+
"/evp_proxy/v2/",
18+
"/evp_proxy/v3/",
19+
"/evp_proxy/v4/",
20+
"/debugger/v1/input",
21+
"/debugger/v1/diagnostics",
22+
"/symdb/v1/input",
23+
"/dogstatsd/v1/proxy",
24+
"/dogstatsd/v2/proxy",
25+
"/tracer_flare/v1",
26+
"/config/set"
27+
],
28+
"client_drop_p0s": true,
29+
"span_meta_structs": true,
30+
"long_running_spans": true,
31+
"span_events": true,
32+
"config": {
33+
"default_env": "prod",
34+
"target_tps": 10,
35+
"max_eps": 200,
36+
"receiver_port": 8127,
37+
"receiver_socket": "/var/run/datadog/apm.socket",
38+
"connection_limit": 12,
39+
"receiver_timeout": 100,
40+
"max_request_bytes": 26214400,
41+
"statsd_port": 8125,
42+
"max_memory": 0,
43+
"max_cpu": 0,
44+
"analyzed_spans_by_service": {},
45+
"obfuscation": {
46+
"elastic_search": true,
47+
"mongo": true,
48+
"sql_exec_plan": true,
49+
"sql_exec_plan_normalize": true,
50+
"http": {
51+
"remove_query_string": true,
52+
"remove_path_digits": true
53+
},
54+
"remove_stack_traces": false,
55+
"redis": true,
56+
"memcached": false
57+
}
58+
},
59+
"peer_tags": [
60+
"_dd.base_service",
61+
"active_record.db.vendor",
62+
"amqp.destination",
63+
"amqp.exchange",
64+
"amqp.queue",
65+
"grpc.host",
66+
"hostname",
67+
"http.host",
68+
"http.server_name",
69+
"streamname",
70+
"tablename",
71+
"topicname"
72+
],
73+
"span_kinds_stats_computed": [
74+
"server",
75+
"consumer",
76+
"client",
77+
"producer"
78+
],
79+
"obfuscation_version": 1
80+
}

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static datadog.trace.api.cache.RadixTreeCache.UNSET_STATUS;
55
import static datadog.trace.api.datastreams.DataStreamsContext.forHttpServer;
66
import static datadog.trace.api.gateway.Events.EVENTS;
7-
import static datadog.trace.bootstrap.instrumentation.api.AgentPropagation.extractContextAndGetSpanContext;
87
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.traceConfig;
98
import static datadog.trace.bootstrap.instrumentation.decorator.http.HttpResourceDecorator.HTTP_RESOURCE_DECORATOR;
109

@@ -119,32 +118,14 @@ protected AgentTracer.TracerAPI tracer() {
119118
return AgentTracer.get();
120119
}
121120

122-
/** Deprecated. Use {@link #extractContext(REQUEST_CARRIER)} instead. */
123-
public AgentSpanContext.Extracted extract(REQUEST_CARRIER carrier) {
124-
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
125-
if (null == carrier || null == getter) {
126-
return null;
127-
}
128-
return extractContextAndGetSpanContext(carrier, getter);
129-
}
130-
131-
/**
132-
* Will be renamed to #extract(REQUEST_CARRIER) when refactoring of instrumentations is complete
133-
*/
134-
public Context extractContext(REQUEST_CARRIER carrier) {
121+
public Context extract(REQUEST_CARRIER carrier) {
135122
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
136123
if (null == carrier || null == getter) {
137124
return root();
138125
}
139126
return Propagators.defaultPropagator().extract(root(), carrier, getter);
140127
}
141128

142-
/** Deprecated. Use {@link #startSpan(Object, Context)} instead. */
143-
@Deprecated
144-
public AgentSpan startSpan(REQUEST_CARRIER carrier, AgentSpanContext.Extracted context) {
145-
return startSpan("http-server", carrier, context);
146-
}
147-
148129
public AgentSpan startSpan(
149130
String instrumentationName, REQUEST_CARRIER carrier, AgentSpanContext.Extracted context) {
150131
AgentSpan span =

dd-java-agent/agent-llmobs/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies {
2929
implementation project(':internal-api')
3030

3131
testImplementation project(":utils:test-utils")
32+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.12.0'
3233

3334
testFixturesApi project(':dd-java-agent:testing')
3435
testFixturesApi project(':utils:test-utils')

dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogWrapperHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class DatadogWrapperHelper {
1212
public static ContextScope createSpan(final HttpRequest request) {
13-
final Context context = DECORATE.extractContext(request);
13+
final Context context = DECORATE.extract(request);
1414
final AgentSpan span = DECORATE.startSpan(request, context);
1515
DECORATE.afterStart(span);
1616
DECORATE.onRequest(span, request, request, context);

dd-java-agent/instrumentation/azure-functions/src/main/java/datadog/trace/instrumentation/azure/functions/AzureFunctionsInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static class AzureFunctionsAdvice {
6767
public static ContextScope methodEnter(
6868
@Advice.Argument(0) final HttpRequestMessage request,
6969
@Advice.Argument(1) final ExecutionContext context) {
70-
final Context extractedContext = DECORATE.extractContext(request);
70+
final Context extractedContext = DECORATE.extract(request);
7171
final AgentSpan span = DECORATE.startSpan(request, extractedContext);
7272
DECORATE.afterStart(span, context.getFunctionName());
7373
DECORATE.onRequest(span, request, request, extractedContext);

dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static class HandleAdvice {
7373
return false;
7474
}
7575

76-
final Context parentContext = DECORATE.extractContext(request);
76+
final Context parentContext = DECORATE.extract(request);
7777
final AgentSpan span = DECORATE.startSpan(request, parentContext);
7878
DECORATE.afterStart(span);
7979
DECORATE.onRequest(span, request, request, parentContext);

0 commit comments

Comments
 (0)