Skip to content

Commit a44e017

Browse files
committed
Drop rare sampling support on CSS
1 parent 316ea27 commit a44e017

File tree

3 files changed

+10
-52
lines changed

3 files changed

+10
-52
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,9 @@ private boolean publish(CoreSpan<?> span, boolean isTopLevel) {
319319
SPAN_KINDS.computeIfAbsent(
320320
spanKind, UTF8BytesString::create), // save repeated utf8 conversions
321321
getPeerTags(span, spanKind.toString()));
322-
boolean isNewKey = false;
323322
MetricKey key = keys.putIfAbsent(newKey, newKey);
324323
if (null == key) {
325324
key = newKey;
326-
isNewKey = true;
327325
}
328326
long tag = (span.getError() > 0 ? ERROR_TAG : 0L) | (isTopLevel ? TOP_LEVEL_TAG : 0L);
329327
long durationNanos = span.getDurationNano();
@@ -340,7 +338,6 @@ private boolean publish(CoreSpan<?> span, boolean isTopLevel) {
340338
}
341339
// recycle the older key
342340
key = batch.getKey();
343-
isNewKey = false;
344341
}
345342
batch = newBatch(key);
346343
batch.add(tag, durationNanos);
@@ -349,8 +346,8 @@ private boolean publish(CoreSpan<?> span, boolean isTopLevel) {
349346
pending.put(key, batch);
350347
// must offer to the queue after adding to pending
351348
inbox.offer(batch);
352-
// force keep keys we haven't seen before or errors
353-
return isNewKey || span.getError() > 0;
349+
// force keep keys if there are errors
350+
return span.getError() > 0;
354351
}
355352

356353
private List<UTF8BytesString> getPeerTags(CoreSpan<?> span, String spanKind) {

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -661,45 +661,6 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
661661
aggregator.close()
662662
}
663663

664-
def "aggregator should force keep the first of each key it sees"() {
665-
setup:
666-
int maxAggregates = 10
667-
MetricWriter writer = Mock(MetricWriter)
668-
Sink sink = Stub(Sink)
669-
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
670-
features.supportsMetrics() >> true
671-
features.peerTags() >> []
672-
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(empty,
673-
features, HealthMetrics.NO_OP, sink, writer, maxAggregates, queueSize, 1, SECONDS)
674-
long duration = 100
675-
aggregator.start()
676-
677-
when:
678-
def overrides = new boolean[10]
679-
for (int i = 0; i < 5; ++i) {
680-
overrides[i] = aggregator.publish([
681-
new SimpleSpan("service" + i, "operation", "resource", "type", false, true, false, 0, duration, HTTP_OK)
682-
])
683-
}
684-
for (int i = 0; i < 5; ++i) {
685-
overrides[i + 5] = aggregator.publish([
686-
new SimpleSpan("service" + i, "operation", "resource", "type", false, true, false, 0, duration, HTTP_OK)
687-
])
688-
}
689-
690-
then: "override only the first of each point in the interval"
691-
for (int i = 0; i < 5; ++i) {
692-
assert overrides[i]
693-
}
694-
// these were all repeats, so should be ignored
695-
for (int i = 5; i < 10; ++i) {
696-
assert !overrides[i]
697-
}
698-
699-
cleanup:
700-
aggregator.close()
701-
}
702-
703664
def "should be resilient to serialization errors"() {
704665
setup:
705666
int maxAggregates = 10

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class MetricsReliabilityTest extends DDCoreSpecification {
8282
then: "should have sent statistics and informed the agent that we calculate the stats"
8383
assert state.receivedClientComputedHeader
8484
assert state.receivedStats
85-
// 1 trace processed. not a p0 drop (first time we see it). No errors
86-
assertMetrics(healthMetrics, 1, 0, 1, 0, 0)
85+
// 1 trace processed. 1 p0 drop No errors
86+
assertMetrics(healthMetrics, 1, 1, 1, 0, 0)
8787

8888

8989
when: "simulate an agent downgrade"
@@ -95,8 +95,8 @@ class MetricsReliabilityTest extends DDCoreSpecification {
9595
then: "a discovery should have done - we do not support anymore stats calculation"
9696
state.latch.await()
9797
assert !featuresDiscovery.supportsMetrics()
98-
// 2 traces processed. 1 p0 dropped. 2 requests and 1 downgrade no errors
99-
assertMetrics(healthMetrics, 2, 1, 2, 0, 1)
98+
// 2 traces processed. 2 p0 dropped. 2 requests and 1 downgrade no errors
99+
assertMetrics(healthMetrics, 2, 2, 2, 0, 1)
100100

101101

102102
when: "a span is published"
@@ -109,7 +109,7 @@ class MetricsReliabilityTest extends DDCoreSpecification {
109109
assert !state.receivedClientComputedHeader
110110
assert !state.receivedStats
111111
// 2 traces processed. 1 p0 dropped. 2 requests and 1 downgrade no errors
112-
assertMetrics(healthMetrics, 2, 1, 2, 0, 1)
112+
assertMetrics(healthMetrics, 2, 2, 2, 0, 1)
113113

114114
when: "we detect that the agent can calculate the stats again"
115115
state.reset(true)
@@ -128,7 +128,7 @@ class MetricsReliabilityTest extends DDCoreSpecification {
128128
assert state.receivedClientComputedHeader
129129
assert state.receivedStats
130130
// 3 traces processed. 2 p0 dropped. 3 requests and 1 downgrade no errors
131-
assertMetrics(healthMetrics, 3, 2, 3, 0, 1)
131+
assertMetrics(healthMetrics, 3, 3, 3, 0, 1)
132132

133133
when: "an error occurred on the agent stats endpoint"
134134
state.reset(true, 500)
@@ -140,7 +140,7 @@ class MetricsReliabilityTest extends DDCoreSpecification {
140140
assert state.receivedClientComputedHeader
141141
assert state.receivedStats
142142
// 4 traces processed. 3 p0 dropped. 4 requests and 1 downgrade - 1 error
143-
assertMetrics(healthMetrics, 4, 3, 4, 1, 1)
143+
assertMetrics(healthMetrics, 4, 4, 4, 1, 1)
144144

145145
when: "the next call succeed"
146146
state.reset(true)
@@ -153,7 +153,7 @@ class MetricsReliabilityTest extends DDCoreSpecification {
153153
assert state.receivedStats
154154
// 5 traces processed. 3 p0 dropped (this one is errored so it's not dropped).
155155
// 5 requests and 1 downgrade - 1 error
156-
assertMetrics(healthMetrics, 5, 3, 5, 1, 1)
156+
assertMetrics(healthMetrics, 5, 4, 5, 1, 1)
157157

158158
cleanup:
159159
tracer.close()

0 commit comments

Comments
 (0)