Skip to content

Commit ee2eb03

Browse files
bric3mhlidd
authored andcommitted
chore(css): Backpropagate peer tags (#9144)
1 parent 06c162d commit ee2eb03

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed

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+
}

0 commit comments

Comments
 (0)