From ec54b9168963a015ac25e2586a16d64f8d31d9fa Mon Sep 17 00:00:00 2001 From: Alexey Kuznetsov Date: Fri, 13 Feb 2026 14:53:14 -0500 Subject: [PATCH 1/2] Clarify endpoint constant naming to avoid confusion between `vX` and `v0.X` versions. --- .../ddagent/DDAgentFeaturesDiscovery.java | 20 +++---- .../DDAgentFeaturesDiscoveryTest.groovy | 52 +++++++++++-------- .../metrics/ConflatingMetricsAggregator.java | 4 +- .../ddagent/DDAgentMapperDiscovery.java | 6 ++- .../TracerConnectionReliabilityTest.groovy | 2 +- .../common/metrics/OkHttpSinkTest.groovy | 6 +-- .../common/writer/WriterFactoryTest.groovy | 2 +- .../trace/test/util/AssertionsUtils.java | 2 +- 8 files changed, 52 insertions(+), 42 deletions(-) diff --git a/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java b/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java index bf8a6edaf71..fd4fda6b6e3 100644 --- a/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java +++ b/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java @@ -46,12 +46,12 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy { (byte) FIXARRAY | 2, (byte) FIXARRAY, (byte) FIXARRAY }; - public static final String V3_ENDPOINT = "v0.3/traces"; - public static final String V4_ENDPOINT = "v0.4/traces"; - public static final String V5_ENDPOINT = "v0.5/traces"; + public static final String V03_ENDPOINT = "v0.3/traces"; + public static final String V04_ENDPOINT = "v0.4/traces"; + public static final String V05_ENDPOINT = "v0.5/traces"; - public static final String V6_METRICS_ENDPOINT = "v0.6/stats"; - public static final String V7_CONFIG_ENDPOINT = "v0.7/config"; + public static final String V06_METRICS_ENDPOINT = "v0.6/stats"; + public static final String V07_CONFIG_ENDPOINT = "v0.7/config"; public static final String V01_DATASTREAMS_ENDPOINT = "v0.1/pipeline_stats"; @@ -72,8 +72,8 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy { private final HttpUrl agentBaseUrl; private final Recording discoveryTimer; private final String[] traceEndpoints; - private final String[] metricsEndpoints = {V6_METRICS_ENDPOINT}; - private final String[] configEndpoints = {V7_CONFIG_ENDPOINT}; + private final String[] metricsEndpoints = {V06_METRICS_ENDPOINT}; + private final String[] configEndpoints = {V07_CONFIG_ENDPOINT}; private final boolean metricsEnabled; private final String[] dataStreamsEndpoints = {V01_DATASTREAMS_ENDPOINT}; // ordered from most recent to least recent, as the logic will stick with the first one that is @@ -113,8 +113,8 @@ public DDAgentFeaturesDiscovery( this.metricsEnabled = metricsEnabled; this.traceEndpoints = enableV05Traces - ? new String[] {V5_ENDPOINT, V4_ENDPOINT, V3_ENDPOINT} - : new String[] {V4_ENDPOINT, V3_ENDPOINT}; + ? new String[] {V05_ENDPOINT, V04_ENDPOINT, V03_ENDPOINT} + : new String[] {V04_ENDPOINT, V03_ENDPOINT}; this.discoveryTimer = monitoring.newTimer("trace.agent.discovery.time"); this.discoveryState = new State(); } @@ -217,7 +217,7 @@ private String probeTracesEndpoint(State newState, String[] endpoints) { errorQueryingEndpoint(candidate, e); } } - return V3_ENDPOINT; + return V03_ENDPOINT; } private void processInfoResponseHeaders(Response response) { diff --git a/communication/src/test/groovy/datadog/communication/ddagent/DDAgentFeaturesDiscoveryTest.groovy b/communication/src/test/groovy/datadog/communication/ddagent/DDAgentFeaturesDiscoveryTest.groovy index e2a5e02d6d2..21015d3c763 100644 --- a/communication/src/test/groovy/datadog/communication/ddagent/DDAgentFeaturesDiscoveryTest.groovy +++ b/communication/src/test/groovy/datadog/communication/ddagent/DDAgentFeaturesDiscoveryTest.groovy @@ -1,9 +1,19 @@ package datadog.communication.ddagent +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V01_DATASTREAMS_ENDPOINT +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V04_ENDPOINT +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V05_ENDPOINT +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V06_METRICS_ENDPOINT +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V07_CONFIG_ENDPOINT +import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_ID +import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_TAGS_HASH + import datadog.common.container.ContainerInfo import datadog.metrics.api.Monitoring import datadog.trace.test.util.DDSpecification import datadog.trace.util.Strings +import java.nio.file.Files +import java.nio.file.Paths import okhttp3.Call import okhttp3.Headers import okhttp3.HttpUrl @@ -15,15 +25,6 @@ import okhttp3.Response import okhttp3.ResponseBody import spock.lang.Shared -import java.nio.file.Files -import java.nio.file.Paths - -import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V01_DATASTREAMS_ENDPOINT -import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V6_METRICS_ENDPOINT -import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V7_CONFIG_ENDPOINT -import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_ID -import static datadog.communication.http.OkHttpUtils.DATADOG_CONTAINER_TAGS_HASH - class DDAgentFeaturesDiscoveryTest extends DDSpecification { @Shared @@ -50,20 +51,20 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { def "test parse /info response"() { setup: OkHttpClient client = Mock(OkHttpClient) - DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, true, true) + DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, v05Enabled, true) when: "/info available" features.discover() then: 1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_RESPONSE) } - features.getMetricsEndpoint() == V6_METRICS_ENDPOINT + features.getMetricsEndpoint() == V06_METRICS_ENDPOINT !features.supportsMetrics() - features.getTraceEndpoint() == "v0.5/traces" + features.getTraceEndpoint() == expectedTraceEndpoint features.getDataStreamsEndpoint() == V01_DATASTREAMS_ENDPOINT features.supportsDataStreams() features.state() == INFO_STATE - features.getConfigEndpoint() == V7_CONFIG_ENDPOINT + features.getConfigEndpoint() == V07_CONFIG_ENDPOINT features.supportsDebugger() features.getDebuggerSnapshotEndpoint() == "debugger/v2/input" features.supportsDebuggerDiagnostics() @@ -74,6 +75,11 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { !features.supportsLongRunning() !features.supportsTelemetryProxy() 0 * _ + + where: + v05Enabled | expectedTraceEndpoint + false | V04_ENDPOINT + true | V05_ENDPOINT } def "Should change discovery state atomically after discovery happened"() { @@ -114,13 +120,13 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { then: 1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_RESPONSE) } - features.getMetricsEndpoint() == V6_METRICS_ENDPOINT + features.getMetricsEndpoint() == V06_METRICS_ENDPOINT !features.supportsMetrics() - features.getTraceEndpoint() == "v0.5/traces" + features.getTraceEndpoint() == V05_ENDPOINT features.getDataStreamsEndpoint() == V01_DATASTREAMS_ENDPOINT features.supportsDataStreams() features.state() == INFO_STATE - features.getConfigEndpoint() == V7_CONFIG_ENDPOINT + features.getConfigEndpoint() == V07_CONFIG_ENDPOINT features.supportsDebugger() features.supportsDebuggerDiagnostics() features.supportsEvpProxy() @@ -140,9 +146,9 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { then: 1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_WITH_CLIENT_DROPPING_RESPONSE) } - features.getMetricsEndpoint() == V6_METRICS_ENDPOINT + features.getMetricsEndpoint() == V06_METRICS_ENDPOINT features.supportsMetrics() - features.getTraceEndpoint() == "v0.5/traces" + features.getTraceEndpoint() == V05_ENDPOINT features.state() == INFO_WITH_CLIENT_DROPPING_STATE 0 * _ } @@ -158,9 +164,9 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { then: 1 * client.newCall(_) >> { Request request -> infoResponse(request, INFO_WITHOUT_DATA_STREAMS_RESPONSE) } - features.getMetricsEndpoint() == V6_METRICS_ENDPOINT + features.getMetricsEndpoint() == V06_METRICS_ENDPOINT !features.supportsMetrics() - features.getTraceEndpoint() == "v0.5/traces" + features.getTraceEndpoint() == V05_ENDPOINT features.getDataStreamsEndpoint() == null !features.supportsDataStreams() features.state() == INFO_WITHOUT_DATA_STREAMS_STATE @@ -197,7 +203,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { 0 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/v0.3/traces" }) >> { Request request -> success(request) } features.getMetricsEndpoint() == null !features.supportsMetrics() - features.getTraceEndpoint() == "v0.5/traces" + features.getTraceEndpoint() == V05_ENDPOINT !features.supportsLongRunning() features.state() == PROBE_STATE 0 * _ @@ -217,7 +223,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { 1 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/v0.5/traces" }) >> { Request request -> success(request) } features.getMetricsEndpoint() == null !features.supportsMetrics() - features.getTraceEndpoint() == "v0.5/traces" + features.getTraceEndpoint() == V05_ENDPOINT !features.supportsLongRunning() features.state() == PROBE_STATE 0 * _ @@ -499,7 +505,7 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification { """ infoResponse(request, response) } - features.getMetricsEndpoint() == V6_METRICS_ENDPOINT + features.getMetricsEndpoint() == V06_METRICS_ENDPOINT features.supportsMetrics() == expected where: diff --git a/dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java b/dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java index fd0a28c2d76..f6e35e3a755 100644 --- a/dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java +++ b/dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java @@ -1,6 +1,6 @@ package datadog.trace.common.metrics; -import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V6_METRICS_ENDPOINT; +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V06_METRICS_ENDPOINT; import static datadog.trace.api.DDTags.BASE_SERVICE; import static datadog.trace.api.Functions.UTF8_ENCODE; import static datadog.trace.bootstrap.instrumentation.api.Tags.HTTP_ENDPOINT; @@ -118,7 +118,7 @@ public ConflatingMetricsAggregator( new OkHttpSink( sharedCommunicationObjects.agentHttpClient, sharedCommunicationObjects.agentUrl.toString(), - V6_METRICS_ENDPOINT, + V06_METRICS_ENDPOINT, config.isTracerMetricsBufferingEnabled(), false, DEFAULT_HEADERS), diff --git a/dd-trace-core/src/main/java/datadog/trace/common/writer/ddagent/DDAgentMapperDiscovery.java b/dd-trace-core/src/main/java/datadog/trace/common/writer/ddagent/DDAgentMapperDiscovery.java index 0ab8e496302..35caede02ae 100644 --- a/dd-trace-core/src/main/java/datadog/trace/common/writer/ddagent/DDAgentMapperDiscovery.java +++ b/dd-trace-core/src/main/java/datadog/trace/common/writer/ddagent/DDAgentMapperDiscovery.java @@ -1,5 +1,7 @@ package datadog.trace.common.writer.ddagent; +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V05_ENDPOINT; + import datadog.communication.ddagent.DDAgentFeaturesDiscovery; import datadog.trace.common.writer.RemoteMapper; import datadog.trace.common.writer.RemoteMapperDiscovery; @@ -25,11 +27,13 @@ private void reset() { @Override public void discover() { reset(); + if (featuresDiscovery.getTraceEndpoint() == null) { featuresDiscovery.discover(); } + String tracesUrl = featuresDiscovery.getTraceEndpoint(); - if (DDAgentFeaturesDiscovery.V5_ENDPOINT.equalsIgnoreCase(tracesUrl)) { + if (V05_ENDPOINT.equalsIgnoreCase(tracesUrl)) { this.traceMapper = new TraceMapperV0_5(); } else if (null != tracesUrl) { this.traceMapper = new TraceMapperV0_4(); diff --git a/dd-trace-core/src/test/groovy/datadog/trace/TracerConnectionReliabilityTest.groovy b/dd-trace-core/src/test/groovy/datadog/trace/TracerConnectionReliabilityTest.groovy index 379fa1561b9..69b971bee4f 100644 --- a/dd-trace-core/src/test/groovy/datadog/trace/TracerConnectionReliabilityTest.groovy +++ b/dd-trace-core/src/test/groovy/datadog/trace/TracerConnectionReliabilityTest.groovy @@ -152,7 +152,7 @@ class TracerConnectionReliabilityTest extends DDSpecification { @Override String getTraceEndpoint() { - return V4_ENDPOINT + return V04_ENDPOINT } @Override diff --git a/dd-trace-core/src/test/groovy/datadog/trace/common/metrics/OkHttpSinkTest.groovy b/dd-trace-core/src/test/groovy/datadog/trace/common/metrics/OkHttpSinkTest.groovy index 0d65e9463ae..a20fd424301 100644 --- a/dd-trace-core/src/test/groovy/datadog/trace/common/metrics/OkHttpSinkTest.groovy +++ b/dd-trace-core/src/test/groovy/datadog/trace/common/metrics/OkHttpSinkTest.groovy @@ -18,14 +18,14 @@ import static datadog.trace.common.metrics.EventListener.EventType.BAD_PAYLOAD import static datadog.trace.common.metrics.EventListener.EventType.DOWNGRADED import static datadog.trace.common.metrics.EventListener.EventType.ERROR import static datadog.trace.common.metrics.EventListener.EventType.OK -import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V6_METRICS_ENDPOINT +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V06_METRICS_ENDPOINT class OkHttpSinkTest extends DDSpecification { def "http status code #responseCode yields #eventType"() { setup: String agentUrl = "http://localhost:8126" - String path = V6_METRICS_ENDPOINT + String path = V06_METRICS_ENDPOINT EventListener listener = Mock(EventListener) OkHttpClient client = Mock(OkHttpClient) OkHttpSink sink = new OkHttpSink(client, agentUrl, path, true, false, Collections.emptyMap()) @@ -58,7 +58,7 @@ class OkHttpSinkTest extends DDSpecification { // them if it's possible not to. setup: String agentUrl = "http://localhost:8126" - String path = V6_METRICS_ENDPOINT + String path = V06_METRICS_ENDPOINT CountDownLatch latch = new CountDownLatch(2) EventListener listener = new BlockingListener(latch) OkHttpClient client = Mock(OkHttpClient) diff --git a/dd-trace-core/src/test/groovy/datadog/trace/common/writer/WriterFactoryTest.groovy b/dd-trace-core/src/test/groovy/datadog/trace/common/writer/WriterFactoryTest.groovy index 25fd88399c0..70124a330d0 100644 --- a/dd-trace-core/src/test/groovy/datadog/trace/common/writer/WriterFactoryTest.groovy +++ b/dd-trace-core/src/test/groovy/datadog/trace/common/writer/WriterFactoryTest.groovy @@ -172,7 +172,7 @@ class WriterFactoryTest extends DDSpecification { } else if (hasEvpProxy) { endpoints = [DDAgentFeaturesDiscovery.V2_EVP_PROXY_ENDPOINT] } else { - endpoints = [DDAgentFeaturesDiscovery.V4_ENDPOINT] + endpoints = [DDAgentFeaturesDiscovery.V04_ENDPOINT] } def response = [ diff --git a/utils/test-utils/src/main/java/datadog/trace/test/util/AssertionsUtils.java b/utils/test-utils/src/main/java/datadog/trace/test/util/AssertionsUtils.java index db5651c2435..d846b61bcc3 100644 --- a/utils/test-utils/src/main/java/datadog/trace/test/util/AssertionsUtils.java +++ b/utils/test-utils/src/main/java/datadog/trace/test/util/AssertionsUtils.java @@ -6,7 +6,7 @@ public class AssertionsUtils { private AssertionsUtils() { - // Bo-op. + // No-op. } public static void assertMapContainsKeyValues(Map actual, Map expectedSubset) { From 683784a98bcca8d19b0848c0681fa923cb6ebf50 Mon Sep 17 00:00:00 2001 From: Alexey Kuznetsov Date: Fri, 13 Feb 2026 15:48:35 -0500 Subject: [PATCH 2/2] Fixed missing const. --- .../groovy/MetricsIntegrationTest.groovy | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dd-trace-core/src/traceAgentTest/groovy/MetricsIntegrationTest.groovy b/dd-trace-core/src/traceAgentTest/groovy/MetricsIntegrationTest.groovy index fd60a54e0f2..3316d79c4de 100644 --- a/dd-trace-core/src/traceAgentTest/groovy/MetricsIntegrationTest.groovy +++ b/dd-trace-core/src/traceAgentTest/groovy/MetricsIntegrationTest.groovy @@ -1,4 +1,7 @@ -import datadog.communication.ddagent.DDAgentFeaturesDiscovery +import static datadog.communication.ddagent.DDAgentFeaturesDiscovery.V06_METRICS_ENDPOINT +import static datadog.trace.common.metrics.EventListener.EventType.OK +import static java.util.concurrent.TimeUnit.SECONDS + import datadog.communication.http.OkHttpUtils import datadog.metrics.api.Histograms import datadog.metrics.impl.DDSketchHistograms @@ -10,14 +13,10 @@ import datadog.trace.common.metrics.EventListener import datadog.trace.common.metrics.MetricKey import datadog.trace.common.metrics.OkHttpSink import datadog.trace.common.metrics.SerializingMetricWriter -import okhttp3.HttpUrl - import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch import java.util.concurrent.atomic.AtomicLongArray - -import static datadog.trace.common.metrics.EventListener.EventType.OK -import static java.util.concurrent.TimeUnit.SECONDS +import okhttp3.HttpUrl class MetricsIntegrationTest extends AbstractTraceAgentTest { @@ -31,7 +30,7 @@ class MetricsIntegrationTest extends AbstractTraceAgentTest { def latch = new CountDownLatch(1) def listener = new BlockingListener(latch) def agentUrl = Config.get().getAgentUrl() - OkHttpSink sink = new OkHttpSink(OkHttpUtils.buildHttpClient(HttpUrl.parse(agentUrl), 5000L), agentUrl, DDAgentFeaturesDiscovery.V6_METRICS_ENDPOINT, true, false, [:]) + OkHttpSink sink = new OkHttpSink(OkHttpUtils.buildHttpClient(HttpUrl.parse(agentUrl), 5000L), agentUrl, V06_METRICS_ENDPOINT, true, false, [:]) sink.register(listener) when: