Skip to content

Commit 886907e

Browse files
committed
feat(metrics): Config to disable agent version check for trace stats computation
1 parent aa7c70f commit 886907e

File tree

15 files changed

+67
-38
lines changed

15 files changed

+67
-38
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
7676
private final String[] metricsEndpoints = {V06_METRICS_ENDPOINT};
7777
private final String[] configEndpoints = {V07_CONFIG_ENDPOINT};
7878
private final boolean metricsEnabled;
79+
private final boolean ignoreAgentVersionForStats;
7980
private final String[] dataStreamsEndpoints = {V01_DATASTREAMS_ENDPOINT};
8081
// ordered from most recent to least recent, as the logic will stick with the first one that is
8182
// available
@@ -108,10 +109,12 @@ public DDAgentFeaturesDiscovery(
108109
Monitoring monitoring,
109110
HttpUrl agentUrl,
110111
boolean enableV05Traces,
111-
boolean metricsEnabled) {
112+
boolean metricsEnabled,
113+
boolean ignoreAgentVersionForStats) {
112114
this.client = client;
113115
this.agentBaseUrl = agentUrl;
114116
this.metricsEnabled = metricsEnabled;
117+
this.ignoreAgentVersionForStats = ignoreAgentVersionForStats;
115118
this.traceEndpoints =
116119
enableV05Traces
117120
? new String[] {V05_ENDPOINT, V04_ENDPOINT, V03_ENDPOINT}
@@ -301,7 +304,9 @@ private boolean processInfoResponse(State newState, String response) {
301304
|| Boolean.TRUE.equals(canDrop));
302305

303306
newState.supportsClientSideStats =
304-
newState.supportsDropping && !AgentVersion.isVersionBelow(newState.version, 7, 65, 0);
307+
newState.supportsDropping
308+
&& (ignoreAgentVersionForStats
309+
|| !AgentVersion.isVersionBelow(newState.version, 7, 65, 0));
305310

306311
Object peer_tags = map.get("peer_tags");
307312
newState.peerTags =

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ public DDAgentFeaturesDiscovery featuresDiscovery(Config config) {
174174
monitoring,
175175
agentUrl,
176176
config.isTraceAgentV05Enabled(),
177-
config.isTracerMetricsEnabled());
177+
config.isTracerMetricsEnabled(),
178+
config.isTracerMetricsIgnoreAgentVersion());
178179

179180
if (paused) {
180181
// defer remote discovery until remote I/O is allowed

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
5151
def "test parse /info response"() {
5252
setup:
5353
OkHttpClient client = Mock(OkHttpClient)
54-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, v05Enabled, true)
54+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, v05Enabled, true, false)
5555

5656
when: "/info available"
5757
features.discover()
@@ -85,7 +85,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
8585
def "Should change discovery state atomically after discovery happened"() {
8686
setup:
8787
OkHttpClient client = Mock(OkHttpClient)
88-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
88+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
8989

9090
when: "/info available"
9191
features.discover()
@@ -111,7 +111,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
111111
def "test parse /info response with discoverIfOutdated"() {
112112
setup:
113113
OkHttpClient client = Mock(OkHttpClient)
114-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
114+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
115115

116116
when: "/info available"
117117
features.discoverIfOutdated()
@@ -139,7 +139,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
139139
def "test parse /info response with client dropping"() {
140140
setup:
141141
OkHttpClient client = Mock(OkHttpClient)
142-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
142+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
143143

144144
when: "/info available"
145145
features.discover()
@@ -157,7 +157,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
157157
def "test parse /info response with data streams unavailable"() {
158158
setup:
159159
OkHttpClient client = Mock(OkHttpClient)
160-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
160+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
161161

162162
when: "/info available"
163163
features.discover()
@@ -176,7 +176,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
176176
def "test parse /info response with long running spans available"() {
177177
setup:
178178
OkHttpClient client = Mock(OkHttpClient)
179-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
179+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
180180

181181
when: "/info available"
182182
features.discover()
@@ -190,7 +190,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
190190
def "test fallback when /info empty"() {
191191
setup:
192192
OkHttpClient client = Mock(OkHttpClient)
193-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true)
193+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true, false)
194194

195195
when: "/info is empty"
196196
features.discover()
@@ -212,7 +212,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
212212
def "test fallback when /info not found"() {
213213
setup:
214214
OkHttpClient client = Mock(OkHttpClient)
215-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
215+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
216216

217217
when: "/info unavailable"
218218
features.discover()
@@ -234,7 +234,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
234234
def "test fallback when /info not found and agent returns ok"() {
235235
setup:
236236
OkHttpClient client = Mock(OkHttpClient)
237-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
237+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
238238

239239
when: "/info unavailable"
240240
features.discover()
@@ -254,7 +254,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
254254
def "test fallback when /info not found and v0.5 disabled"() {
255255
setup:
256256
OkHttpClient client = Mock(OkHttpClient)
257-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true)
257+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true, false)
258258

259259
when: "/info unavailable"
260260
features.discover()
@@ -275,7 +275,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
275275
def "test fallback when /info not found and v0.5 unavailable agent side"() {
276276
setup:
277277
OkHttpClient client = Mock(OkHttpClient)
278-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
278+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
279279

280280
when: "/info unavailable"
281281
features.discover()
@@ -296,7 +296,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
296296
def "test fallback on very old agent"() {
297297
setup:
298298
OkHttpClient client = Mock(OkHttpClient)
299-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
299+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
300300

301301
when: "/info unavailable"
302302
features.discover()
@@ -318,7 +318,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
318318
def "disabling metrics disables metrics and dropping"() {
319319
setup:
320320
OkHttpClient client = Mock(OkHttpClient)
321-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, false)
321+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, false, false)
322322

323323
when: "/info unavailable"
324324
features.discover()
@@ -354,7 +354,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
354354
def "discovery of metrics endpoint after agent upgrade enables dropping and metrics"() {
355355
setup:
356356
OkHttpClient client = Mock(OkHttpClient)
357-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true)
357+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true, false)
358358

359359
when: "/info unavailable"
360360
features.discover()
@@ -382,7 +382,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
382382
def "disappearance of info endpoint after agent downgrade disables metrics and dropping"() {
383383
setup:
384384
OkHttpClient client = Mock(OkHttpClient)
385-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true)
385+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true, false)
386386

387387
when: "/info available"
388388
features.discover()
@@ -411,7 +411,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
411411
def "disappearance of metrics endpoint after agent downgrade disables metrics and dropping"() {
412412
setup:
413413
OkHttpClient client = Mock(OkHttpClient)
414-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true)
414+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true, false)
415415

416416
when: "/info available"
417417
features.discover()
@@ -441,7 +441,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
441441
def "test parse /info response with telemetry proxy"() {
442442
setup:
443443
OkHttpClient client = Mock(OkHttpClient)
444-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
444+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
445445

446446
when: "/info available"
447447
features.discover()
@@ -458,7 +458,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
458458
def "test parse /info response with old EVP proxy"() {
459459
setup:
460460
OkHttpClient client = Mock(OkHttpClient)
461-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
461+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
462462

463463
when: "/info available"
464464
features.discover()
@@ -477,7 +477,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
477477
def "test parse /info response with peer tag back propagation"() {
478478
setup:
479479
OkHttpClient client = Mock(OkHttpClient)
480-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
480+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
481481

482482
when: "/info available"
483483
features.discover()
@@ -510,7 +510,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
510510
def "test metrics disabled for agent version below 7.65"() {
511511
setup:
512512
OkHttpClient client = Mock(OkHttpClient)
513-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
513+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
514514

515515
when: "agent version is below 7.65"
516516
features.discover()
@@ -544,7 +544,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
544544
def "test metrics disabled for agent with unparseable version"() {
545545
setup:
546546
OkHttpClient client = Mock(OkHttpClient)
547-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
547+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
548548

549549
when: "agent version is unparseable"
550550
features.discover()
@@ -570,7 +570,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
570570
def "should send container id as header on the info request and parse the hash in the response"() {
571571
setup:
572572
OkHttpClient client = Mock(OkHttpClient)
573-
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true)
573+
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true, false)
574574
def oldContainerId = ContainerInfo.get().getContainerId()
575575
def oldContainerTagsHash = ContainerInfo.get().getContainerTagsHash()
576576
ContainerInfo.get().setContainerId("test")

dd-java-agent/appsec/src/jmh/java/datadog/appsec/benchmark/AppSecBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public Call clone() {
187187

188188
static class StubDDAgentFeaturesDiscovery extends DDAgentFeaturesDiscovery {
189189
public StubDDAgentFeaturesDiscovery(OkHttpClient client) {
190-
super(client, Monitoring.DISABLED, HttpUrl.get("http://localhost:8080/"), false, false);
190+
super(client, Monitoring.DISABLED, HttpUrl.get("http://localhost:8080/"), false, false, false);
191191
}
192192

193193
@Override

dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/InstrumentationSpecification.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ abstract class InstrumentationSpecification extends DDSpecification implements A
387387
// emit traces to the APM Test-Agent for Cross-Tracer Testing Trace Checks
388388
HttpUrl agentUrl = HttpUrl.get("http://" + agentHost + ":" + DEFAULT_TRACE_AGENT_PORT)
389389
OkHttpClient client = buildHttpClient(true, null, null, TimeUnit.SECONDS.toMillis(DEFAULT_AGENT_TIMEOUT))
390-
DDAgentFeaturesDiscovery featureDiscovery = new DDAgentFeaturesDiscovery(client, Monitoring.DISABLED, agentUrl, Config.get().isTraceAgentV05Enabled(), Config.get().isTracerMetricsEnabled())
390+
DDAgentFeaturesDiscovery featureDiscovery = new DDAgentFeaturesDiscovery(client, Monitoring.DISABLED, agentUrl, Config.get().isTraceAgentV05Enabled(), Config.get().isTracerMetricsEnabled(), Config.get().isTracerMetricsIgnoreAgentVersion())
391391
TEST_AGENT_API = new DDAgentApi(client, agentUrl, featureDiscovery, Monitoring.DISABLED, Config.get().isTracerMetricsEnabled())
392392
TEST_AGENT_WRITER = DDAgentWriter.builder().agentApi(TEST_AGENT_API).build()
393393
}

dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/datastreams/MockFeaturesDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class MockFeaturesDiscovery extends DDAgentFeaturesDiscovery {
88
private final boolean supportsDataStreams;
99

1010
public MockFeaturesDiscovery(boolean supportsDataStreams) {
11-
super(null, Monitoring.DISABLED, null, true, true);
11+
super(null, Monitoring.DISABLED, null, true, true, false);
1212
this.supportsDataStreams = supportsDataStreams;
1313
}
1414

dd-trace-api/src/main/java/datadog/trace/api/config/GeneralConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public final class GeneralConfig {
6565
public static final String PERF_METRICS_ENABLED = "trace.perf.metrics.enabled";
6666

6767
public static final String TRACE_STATS_COMPUTATION_ENABLED = "trace.stats.computation.enabled";
68+
public static final String TRACE_STATS_COMPUTATION_IGNORE_AGENT_VERSION =
69+
"trace.stats.computation.ignore.agent.version";
6870
public static final String TRACER_METRICS_ENABLED = "trace.tracer.metrics.enabled";
6971
public static final String TRACER_METRICS_BUFFERING_ENABLED =
7072
"trace.tracer.metrics.buffering.enabled";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static class FixedAgentFeaturesDiscovery extends DDAgentFeaturesDiscovery {
7272

7373
public FixedAgentFeaturesDiscovery(Set<String> peerTags, Set<String> spanKinds) {
7474
// create a fixed discovery with metrics enabled
75-
super(null, Monitoring.DISABLED, null, false, true);
75+
super(null, Monitoring.DISABLED, null, false, true, false);
7676
this.peerTags = peerTags;
7777
this.spanKinds = spanKinds;
7878
}

dd-trace-core/src/main/java/datadog/trace/common/writer/DDAgentWriter.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static class DDAgentWriterBuilder {
3939
Monitoring monitoring = Monitoring.DISABLED;
4040
boolean traceAgentV05Enabled = Config.get().isTraceAgentV05Enabled();
4141
boolean metricsReportingEnabled = Config.get().isTracerMetricsEnabled();
42+
boolean metricsIgnoreAgentVersion = Config.get().isTracerMetricsIgnoreAgentVersion();
4243
private int flushTimeout = 1;
4344
private TimeUnit flushTimeoutUnit = TimeUnit.SECONDS;
4445
boolean alwaysFlush = false;
@@ -113,6 +114,11 @@ public DDAgentWriterBuilder metricsReportingEnabled(boolean metricsReportingEnab
113114
return this;
114115
}
115116

117+
public DDAgentWriterBuilder metricsIgnoreAgentVersion(boolean metricsIgnoreAgentVersion) {
118+
this.metricsIgnoreAgentVersion = metricsIgnoreAgentVersion;
119+
return this;
120+
}
121+
116122
public DDAgentWriterBuilder featureDiscovery(DDAgentFeaturesDiscovery featureDiscovery) {
117123
this.featureDiscovery = featureDiscovery;
118124
return this;
@@ -143,7 +149,12 @@ public DDAgentWriter build() {
143149
if (null == featureDiscovery) {
144150
featureDiscovery =
145151
new DDAgentFeaturesDiscovery(
146-
client, monitoring, agentUrl, traceAgentV05Enabled, metricsReportingEnabled);
152+
client,
153+
monitoring,
154+
agentUrl,
155+
traceAgentV05Enabled,
156+
metricsReportingEnabled,
157+
metricsIgnoreAgentVersion);
147158
}
148159
if (null == agentApi) {
149160
agentApi =

dd-trace-core/src/test/groovy/datadog/trace/TracerConnectionReliabilityTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TracerConnectionReliabilityTest extends DDSpecification {
147147

148148
class FixedTraceEndpointFeaturesDiscovery extends DDAgentFeaturesDiscovery {
149149
FixedTraceEndpointFeaturesDiscovery(SharedCommunicationObjects objects) {
150-
super(objects.agentHttpClient, Monitoring.DISABLED, objects.agentUrl, false, false)
150+
super(objects.agentHttpClient, Monitoring.DISABLED, objects.agentUrl, false, false, false)
151151
}
152152

153153
@Override

0 commit comments

Comments
 (0)