Skip to content

Commit 5832565

Browse files
committed
Hardcode eligible span kind since agent backpropagated are deprecated
1 parent f7cb253 commit 5832565

File tree

6 files changed

+19
-35
lines changed

6 files changed

+19
-35
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
9292
private volatile String version;
9393
private volatile String telemetryProxyEndpoint;
9494
private volatile Set<String> peerTags = emptySet();
95-
private volatile Set<String> spanKindsToComputedStats = emptySet();
9695

9796
private long lastTimeDiscovered;
9897

@@ -127,7 +126,6 @@ private void reset() {
127126
lastTimeDiscovered = 0;
128127
telemetryProxyEndpoint = null;
129128
peerTags = emptySet();
130-
spanKindsToComputedStats = emptySet();
131129
}
132130

133131
/** Run feature discovery, unconditionally. */
@@ -310,12 +308,6 @@ private boolean processInfoResponse(String response) {
310308
peer_tags instanceof List
311309
? unmodifiableSet(new HashSet<>((List<String>) peer_tags))
312310
: emptySet();
313-
314-
Object span_kinds = map.get("span_kinds_stats_computed");
315-
spanKindsToComputedStats =
316-
span_kinds instanceof List
317-
? unmodifiableSet(new HashSet<>((List<String>) span_kinds))
318-
: emptySet();
319311
}
320312
try {
321313
state = Strings.sha256(response);
@@ -377,10 +369,6 @@ public Set<String> peerTags() {
377369
return peerTags;
378370
}
379371

380-
public Set<String> spanKindsToComputedStats() {
381-
return spanKindsToComputedStats;
382-
}
383-
384372
public String getMetricsEndpoint() {
385373
return metricsEndpoint;
386374
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,6 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
462462
"tablename",
463463
"topicname"
464464
)
465-
features.spanKindsToComputedStats().containsAll(
466-
"client",
467-
"consumer",
468-
"producer",
469-
"server"
470-
)
471465
}
472466

473467
def "should send container id as header on the info request and parse the hash in the response"() {

dd-trace-core/src/jmh/java/datadog/trace/common/metrics/ConflatingMetricsAggregatorBenchmark.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public boolean supportsMetrics() {
8888
public Set<String> peerTags() {
8989
return peerTags;
9090
}
91-
92-
@Override
93-
public Set<String> spanKindsToComputedStats() {
94-
return spanKinds;
95-
}
9691
}
9792

9893
@Benchmark

dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V6_METRICS_ENDPOINT;
44
import static datadog.trace.api.Functions.UTF8_ENCODE;
55
import static datadog.trace.bootstrap.instrumentation.api.Tags.SPAN_KIND;
6+
import static datadog.trace.bootstrap.instrumentation.api.Tags.SPAN_KIND_CLIENT;
7+
import static datadog.trace.bootstrap.instrumentation.api.Tags.SPAN_KIND_CONSUMER;
8+
import static datadog.trace.bootstrap.instrumentation.api.Tags.SPAN_KIND_PRODUCER;
9+
import static datadog.trace.bootstrap.instrumentation.api.Tags.SPAN_KIND_SERVER;
610
import static datadog.trace.common.metrics.AggregateMetric.ERROR_TAG;
711
import static datadog.trace.common.metrics.AggregateMetric.TOP_LEVEL_TAG;
812
import static datadog.trace.common.metrics.SignalItem.ReportSignal.REPORT;
913
import static datadog.trace.common.metrics.SignalItem.StopSignal.STOP;
1014
import static datadog.trace.util.AgentThreadFactory.AgentThread.METRICS_AGGREGATOR;
1115
import static datadog.trace.util.AgentThreadFactory.THREAD_JOIN_TIMOUT_MS;
1216
import static datadog.trace.util.AgentThreadFactory.newAgentThread;
17+
import static java.util.Collections.unmodifiableSet;
1318
import static java.util.concurrent.TimeUnit.SECONDS;
1419

1520
import datadog.communication.ddagent.DDAgentFeaturesDiscovery;
@@ -27,7 +32,9 @@
2732
import datadog.trace.core.monitor.HealthMetrics;
2833
import datadog.trace.util.AgentTaskScheduler;
2934
import java.util.ArrayList;
35+
import java.util.Arrays;
3036
import java.util.Collections;
37+
import java.util.HashSet;
3138
import java.util.List;
3239
import java.util.Map;
3340
import java.util.Queue;
@@ -69,6 +76,12 @@ public final class ConflatingMetricsAggregator implements MetricsAggregator, Eve
6976
value -> UTF8BytesString.create(key + ":" + value));
7077
private static final CharSequence SYNTHETICS_ORIGIN = "synthetics";
7178

79+
private static final Set<String> ELIGIBLE_SPAN_KINDS =
80+
unmodifiableSet(
81+
new HashSet<>(
82+
Arrays.asList(
83+
SPAN_KIND_SERVER, SPAN_KIND_CLIENT, SPAN_KIND_CONSUMER, SPAN_KIND_PRODUCER)));
84+
7285
private final Set<String> ignoredResources;
7386
private final Queue<Batch> batchPool;
7487
private final NonBlockingHashMap<MetricKey, Batch> pending;
@@ -280,7 +293,7 @@ private boolean shouldComputeMetric(CoreSpan<?> span) {
280293
private boolean spanKindEligible(CoreSpan<?> span) {
281294
final Object spanKind = span.getTag(SPAN_KIND);
282295
// use toString since it could be a CharSequence...
283-
return spanKind != null && features.spanKindsToComputedStats().contains(spanKind.toString());
296+
return spanKind != null && ELIGIBLE_SPAN_KINDS.contains(spanKind.toString());
284297
}
285298

286299
private boolean publish(CoreSpan<?> span, boolean isTopLevel) {

dd-trace-core/src/test/groovy/datadog/trace/common/metrics/ConflatingMetricAggregatorTest.groovy

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
144144
Sink sink = Stub(Sink)
145145
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
146146
features.supportsMetrics() >> true
147-
features.spanKindsToComputedStats() >> ["client", "server", "producer", "consumer"]
148147
features.peerTags() >> []
149148
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
150149
features, HealthMetrics.NO_OP, sink, writer, 10, queueSize, reportingInterval, SECONDS)
@@ -183,6 +182,8 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
183182
where:
184183
kind | statsComputed
185184
"client" | true
185+
"producer" | true
186+
"consumer" | true
186187
UTF8BytesString.create("server") | true
187188
"internal" | false
188189
null | false
@@ -194,7 +195,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
194195
Sink sink = Stub(Sink)
195196
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
196197
features.supportsMetrics() >> true
197-
features.spanKindsToComputedStats() >> ["grault"]
198198
features.peerTags() >>> [["country"], ["country", "georegion"],]
199199
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
200200
features, sink, writer, 10, queueSize, reportingInterval, SECONDS)
@@ -203,9 +203,9 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
203203
when:
204204
CountDownLatch latch = new CountDownLatch(1)
205205
aggregator.publish([
206-
new SimpleSpan("service", "operation", "resource", "type", false, false, false, 0, 100, HTTP_OK)
206+
new SimpleSpan("service", "operation", "resource", "type", true, false, false, 0, 100, HTTP_OK)
207207
.setTag(SPAN_KIND, "grault").setTag("country", "france").setTag("georegion", "europe"),
208-
new SimpleSpan("service", "operation", "resource", "type", false, false, false, 0, 100, HTTP_OK)
208+
new SimpleSpan("service", "operation", "resource", "type", true, false, false, 0, 100, HTTP_OK)
209209
.setTag(SPAN_KIND, "grault").setTag("country", "france").setTag("georegion", "europe")
210210
])
211211
aggregator.report()
@@ -302,7 +302,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
302302
Sink sink = Stub(Sink)
303303
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
304304
features.supportsMetrics() >> true
305-
features.spanKindsToComputedStats() >> ["baz"]
306305
features.peerTags() >> []
307306
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
308307
features, HealthMetrics.NO_OP, sink, writer, 10, queueSize, reportingInterval, SECONDS)
@@ -368,7 +367,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
368367
Sink sink = Stub(Sink)
369368
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
370369
features.supportsMetrics() >> true
371-
features.spanKindsToComputedStats() >> ["baz"]
372370
features.peerTags() >> []
373371
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
374372
features, HealthMetrics.NO_OP, sink, writer, maxAggregates, queueSize, reportingInterval, SECONDS)
@@ -428,7 +426,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
428426
Sink sink = Stub(Sink)
429427
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
430428
features.supportsMetrics() >> true
431-
features.spanKindsToComputedStats() >> ["baz"]
432429
features.peerTags() >> []
433430
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
434431
features, HealthMetrics.NO_OP, sink, writer, maxAggregates, queueSize, reportingInterval, SECONDS)
@@ -491,7 +488,7 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
491488
true,
492489
"baz",
493490
[]
494-
),{ AggregateMetric value ->
491+
), { AggregateMetric value ->
495492
value.getHitCount() == 1 && value.getDuration() == duration
496493
})
497494
}
@@ -519,7 +516,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
519516
Sink sink = Stub(Sink)
520517
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
521518
features.supportsMetrics() >> true
522-
features.spanKindsToComputedStats() >> ["quux"]
523519
features.peerTags() >> []
524520
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
525521
features, HealthMetrics.NO_OP, sink, writer, maxAggregates, queueSize, reportingInterval, SECONDS)
@@ -576,7 +572,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
576572
Sink sink = Stub(Sink)
577573
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
578574
features.supportsMetrics() >> true
579-
features.spanKindsToComputedStats() >> ["garply"]
580575
features.peerTags() >> []
581576
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
582577
features, HealthMetrics.NO_OP, sink, writer, maxAggregates, queueSize, 1, SECONDS)

dd-trace-core/src/test/groovy/datadog/trace/common/metrics/FootprintForkedTest.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class FootprintForkedTest extends DDSpecification {
2828
ValidatingSink sink = new ValidatingSink(latch)
2929
DDAgentFeaturesDiscovery features = Stub(DDAgentFeaturesDiscovery) {
3030
it.supportsMetrics() >> true
31-
it.spanKindsToComputedStats() >> []
3231
it.peerTags() >> []
3332
}
3433
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(

0 commit comments

Comments
 (0)