From a4287c54a95dedf9368aaf17c3106401cf4b11ad Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Thu, 23 Jul 2026 18:40:11 -0400 Subject: [PATCH 1/3] Add OTLP export flags to tracer startup diagnostic log Report whether the tracer exports each telemetry signal over OTLP in the "DATADOG TRACER CONFIGURATION" startup log via three boolean fields: otlp_traces_export_enabled, otlp_metrics_export_enabled, and otlp_logs_export_enabled. Metrics and logs require both the OTel signal to be enabled and the OTLP exporter to be selected. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../java/datadog/trace/core/StatusLogger.java | 6 ++ .../datadog/trace/core/StatusLoggerTest.java | 61 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java diff --git a/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java b/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java index 78b88d786c9..d6509767ae7 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java @@ -158,6 +158,12 @@ public void toJson(JsonWriter writer, Config config) throws IOException { writer.value(config.isDataStreamsEnabled()); writer.name("data_streams_transaction_extractors"); writer.value(config.getDataStreamsTransactionExtractors()); + writer.name("otlp_traces_export_enabled"); + writer.value(config.isTraceOtlpExporterEnabled()); + writer.name("otlp_metrics_export_enabled"); + writer.value(config.isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled()); + writer.name("otlp_logs_export_enabled"); + writer.value(config.isLogsOtelEnabled() && config.isLogsOtlpExporterEnabled()); writer.name("app_logs_collection_enabled"); writer.value(config.isAppLogsCollectionEnabled()); diff --git a/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java b/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java new file mode 100644 index 00000000000..75795efb052 --- /dev/null +++ b/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java @@ -0,0 +1,61 @@ +package datadog.trace.core; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.squareup.moshi.Moshi; +import datadog.trace.api.Config; +import datadog.trace.api.config.OtlpConfig; +import datadog.trace.test.junit.utils.config.WithConfig; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; + +@Timeout(value = 10, unit = TimeUnit.SECONDS) +public class StatusLoggerTest extends DDCoreJavaSpecification { + + @Test + void otlpExportDisabledByDefault() throws IOException { + Map startupLog = startupLog(Config.get()); + + assertEquals(false, startupLog.get("otlp_traces_export_enabled")); + assertEquals(false, startupLog.get("otlp_metrics_export_enabled")); + assertEquals(false, startupLog.get("otlp_logs_export_enabled")); + } + + @Test + @WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = OtlpConfig.METRICS_OTEL_ENABLED, value = "true") + @WithConfig(key = OtlpConfig.METRICS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = OtlpConfig.LOGS_OTEL_ENABLED, value = "true") + @WithConfig(key = OtlpConfig.LOGS_OTEL_EXPORTER, value = "otlp") + void otlpExportEnabledWhenConfigured() throws IOException { + Map startupLog = startupLog(Config.get()); + + assertEquals(true, startupLog.get("otlp_traces_export_enabled")); + assertEquals(true, startupLog.get("otlp_metrics_export_enabled")); + assertEquals(true, startupLog.get("otlp_logs_export_enabled")); + } + + @Test + @WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = OtlpConfig.METRICS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = OtlpConfig.LOGS_OTEL_EXPORTER, value = "otlp") + void metricsAndLogsRequireOtelSignalEnabled() throws IOException { + // The OTLP exporter is selected for every signal, but the metrics and logs OTel signals are + // left disabled, so only trace export should be reported as enabled. + Map startupLog = startupLog(Config.get()); + + assertEquals(true, startupLog.get("otlp_traces_export_enabled")); + assertEquals(false, startupLog.get("otlp_metrics_export_enabled")); + assertEquals(false, startupLog.get("otlp_logs_export_enabled")); + } + + @SuppressWarnings("unchecked") + private static Map startupLog(Config config) throws IOException { + String json = + new Moshi.Builder().add(new StatusLogger()).build().adapter(Config.class).toJson(config); + return (Map) new Moshi.Builder().build().adapter(Object.class).fromJson(json); + } +} From 6d1065b2e502a82ac264e22349b3ad946ee7f9c4 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Fri, 24 Jul 2026 18:39:25 -0400 Subject: [PATCH 2/3] Base OTLP export flags on effective writer and span metrics Report otlp_traces_export_enabled from the resolved writer type (OtlpWriter) rather than the OTLP exporter selection, since an explicit dd.writer.type override wins over dd.trace.otel.exporter=otlp in WriterFactory. Also report otlp_metrics_export_enabled when client-side span metrics are enabled, since those are exported over OTLP via OtlpStatsMetricWriter independently of the OTel metrics signal. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../java/datadog/trace/core/StatusLogger.java | 13 +++++++++-- .../datadog/trace/core/StatusLoggerTest.java | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java b/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java index d6509767ae7..470471bbc32 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java @@ -2,6 +2,7 @@ import static datadog.trace.api.Config.isDatadogProfilerEnablementOverridden; import static datadog.trace.api.Config.isDatadogProfilerSafeInCurrentEnvironment; +import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.OTLP_WRITER_TYPE; import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.squareup.moshi.JsonAdapter; @@ -159,9 +160,17 @@ public void toJson(JsonWriter writer, Config config) throws IOException { writer.name("data_streams_transaction_extractors"); writer.value(config.getDataStreamsTransactionExtractors()); writer.name("otlp_traces_export_enabled"); - writer.value(config.isTraceOtlpExporterEnabled()); + // Report the effective trace writer, not just the exporter selection: an explicit + // dd.writer.type override wins over dd.trace.otel.exporter=otlp in WriterFactory, so traces are + // only exported over OTLP when the resolved writer is actually the OtlpWriter. + writer.value(OTLP_WRITER_TYPE.equals(config.getWriterType())); writer.name("otlp_metrics_export_enabled"); - writer.value(config.isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled()); + // Client-side trace span-metrics are exported over OTLP whenever span metrics are enabled + // (MetricsAggregatorFactory routes them through OtlpStatsMetricWriter), independently of the + // OTel metrics signal, so OR that path in alongside OTel-API metrics export. + writer.value( + (config.isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled()) + || config.isOtelTracesSpanMetricsEnabled()); writer.name("otlp_logs_export_enabled"); writer.value(config.isLogsOtelEnabled() && config.isLogsOtlpExporterEnabled()); diff --git a/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java b/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java index 75795efb052..8e196fe7695 100644 --- a/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java +++ b/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java @@ -5,6 +5,7 @@ import com.squareup.moshi.Moshi; import datadog.trace.api.Config; import datadog.trace.api.config.OtlpConfig; +import datadog.trace.api.config.TracerConfig; import datadog.trace.test.junit.utils.config.WithConfig; import java.io.IOException; import java.util.Map; @@ -52,6 +53,28 @@ void metricsAndLogsRequireOtelSignalEnabled() throws IOException { assertEquals(false, startupLog.get("otlp_logs_export_enabled")); } + @Test + @WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = TracerConfig.WRITER_TYPE, value = "DDAgentWriter") + void tracesNotExportedWhenWriterTypeOverridesOtlpExporter() throws IOException { + // The OTLP trace exporter is selected, but an explicit dd.writer.type override wins in + // WriterFactory, so the effective writer is the DDAgentWriter and traces are not exported over + // OTLP. + Map startupLog = startupLog(Config.get()); + + assertEquals(false, startupLog.get("otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = OtlpConfig.OTEL_TRACES_SPAN_METRICS_ENABLED, value = "true") + void metricsExportedWhenSpanMetricsEnabled() throws IOException { + // Span metrics are exported over OTLP via OtlpStatsMetricWriter whenever span metrics are + // enabled, independently of the OTel metrics signal, so metrics export should be reported. + Map startupLog = startupLog(Config.get()); + + assertEquals(true, startupLog.get("otlp_metrics_export_enabled")); + } + @SuppressWarnings("unchecked") private static Map startupLog(Config config) throws IOException { String json = From 070e7d8359f1403a08e2fb3147894a133ac1c6ba Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Mon, 27 Jul 2026 11:53:18 -0400 Subject: [PATCH 3/3] Derive OTLP export flags in Config and honor MultiWriter Move the three derived booleans out of StatusLogger.toJson and into Config accessors: isOtlpTracesExportEnabled, isOtlpMetricsExportEnabled, and isOtlpLogsExportEnabled. Every other field toJson emits forwards a Config getter, so keeping the conjunctions inline made this method the only place in the file that derives a value it writes. Fix otlp_traces_export_enabled. It compared dd.writer.type to OtlpWriter for equality, so MultiWriter:OtlpWriter,DDAgentWriter reported false even though WriterFactory builds a real OtlpWriter for it. isOtlpTracesExportEnabled now mirrors WriterFactory's dispatch: a writer type that does not start with MultiWriter is compared to OtlpWriter directly, and one that does has every literal MultiWriter: removed before the remainder is split on commas and each sub-type compared. Removing every occurrence rather than a single leading prefix matches what MultiWriter itself does, so a repeated prefix such as MultiWriter:DDAgentWriter,MultiWriter:OtlpWriter resolves the same way in both places. Drop the two comment blocks in StatusLogger explaining writer precedence and span-metrics routing, and the three in StatusLoggerTest. StatusLogger carries no comments anywhere else, and the reasoning belongs in the commit message and pull request, which both record it. Expand StatusLoggerTest to 13 tests and assert with assertFalse and assertTrue instead of assertEquals against boolean literals. The new cases pin the writer type grammar: a MultiWriter list that includes OtlpWriter, one that excludes it, a repeated MultiWriter prefix, a padded sub-type, a sub-type that only prefixes OtlpWriter, a comma-separated list without the MultiWriter prefix, and a TraceStructureWriter value that WriterFactory dispatches before it ever reaches the MultiWriter branch. Co-Authored-By: Claude Opus 5 --- .../java/datadog/trace/core/StatusLogger.java | 15 +- .../datadog/trace/core/StatusLoggerTest.java | 137 +++++++++++++----- .../main/java/datadog/trace/api/Config.java | 26 ++++ 3 files changed, 126 insertions(+), 52 deletions(-) diff --git a/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java b/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java index 470471bbc32..da324a07def 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java @@ -2,7 +2,6 @@ import static datadog.trace.api.Config.isDatadogProfilerEnablementOverridden; import static datadog.trace.api.Config.isDatadogProfilerSafeInCurrentEnvironment; -import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.OTLP_WRITER_TYPE; import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.squareup.moshi.JsonAdapter; @@ -160,19 +159,11 @@ public void toJson(JsonWriter writer, Config config) throws IOException { writer.name("data_streams_transaction_extractors"); writer.value(config.getDataStreamsTransactionExtractors()); writer.name("otlp_traces_export_enabled"); - // Report the effective trace writer, not just the exporter selection: an explicit - // dd.writer.type override wins over dd.trace.otel.exporter=otlp in WriterFactory, so traces are - // only exported over OTLP when the resolved writer is actually the OtlpWriter. - writer.value(OTLP_WRITER_TYPE.equals(config.getWriterType())); + writer.value(config.isOtlpTracesExportEnabled()); writer.name("otlp_metrics_export_enabled"); - // Client-side trace span-metrics are exported over OTLP whenever span metrics are enabled - // (MetricsAggregatorFactory routes them through OtlpStatsMetricWriter), independently of the - // OTel metrics signal, so OR that path in alongside OTel-API metrics export. - writer.value( - (config.isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled()) - || config.isOtelTracesSpanMetricsEnabled()); + writer.value(config.isOtlpMetricsExportEnabled()); writer.name("otlp_logs_export_enabled"); - writer.value(config.isLogsOtelEnabled() && config.isLogsOtlpExporterEnabled()); + writer.value(config.isOtlpLogsExportEnabled()); writer.name("app_logs_collection_enabled"); writer.value(config.isAppLogsCollectionEnabled()); diff --git a/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java b/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java index 8e196fe7695..14d2ff6a421 100644 --- a/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java +++ b/dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java @@ -1,12 +1,20 @@ package datadog.trace.core; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static datadog.trace.api.config.OtlpConfig.LOGS_OTEL_ENABLED; +import static datadog.trace.api.config.OtlpConfig.LOGS_OTEL_EXPORTER; +import static datadog.trace.api.config.OtlpConfig.METRICS_OTEL_ENABLED; +import static datadog.trace.api.config.OtlpConfig.METRICS_OTEL_EXPORTER; +import static datadog.trace.api.config.OtlpConfig.OTEL_TRACES_SPAN_METRICS_ENABLED; +import static datadog.trace.api.config.OtlpConfig.TRACE_OTEL_EXPORTER; +import static datadog.trace.api.config.TracerConfig.WRITER_TYPE; +import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.DD_AGENT_WRITER_TYPE; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.squareup.moshi.Moshi; import datadog.trace.api.Config; -import datadog.trace.api.config.OtlpConfig; -import datadog.trace.api.config.TracerConfig; import datadog.trace.test.junit.utils.config.WithConfig; +import datadog.trace.test.util.DDJavaSpecification; import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -14,71 +22,120 @@ import org.junit.jupiter.api.Timeout; @Timeout(value = 10, unit = TimeUnit.SECONDS) -public class StatusLoggerTest extends DDCoreJavaSpecification { +public class StatusLoggerTest extends DDJavaSpecification { @Test void otlpExportDisabledByDefault() throws IOException { - Map startupLog = startupLog(Config.get()); + Map startupLog = startupLog(); - assertEquals(false, startupLog.get("otlp_traces_export_enabled")); - assertEquals(false, startupLog.get("otlp_metrics_export_enabled")); - assertEquals(false, startupLog.get("otlp_logs_export_enabled")); + assertFalse(flag(startupLog, "otlp_traces_export_enabled")); + assertFalse(flag(startupLog, "otlp_metrics_export_enabled")); + assertFalse(flag(startupLog, "otlp_logs_export_enabled")); } @Test - @WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp") - @WithConfig(key = OtlpConfig.METRICS_OTEL_ENABLED, value = "true") - @WithConfig(key = OtlpConfig.METRICS_OTEL_EXPORTER, value = "otlp") - @WithConfig(key = OtlpConfig.LOGS_OTEL_ENABLED, value = "true") - @WithConfig(key = OtlpConfig.LOGS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = TRACE_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = METRICS_OTEL_ENABLED, value = "true") + @WithConfig(key = METRICS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = LOGS_OTEL_ENABLED, value = "true") + @WithConfig(key = LOGS_OTEL_EXPORTER, value = "otlp") void otlpExportEnabledWhenConfigured() throws IOException { - Map startupLog = startupLog(Config.get()); + Map startupLog = startupLog(); - assertEquals(true, startupLog.get("otlp_traces_export_enabled")); - assertEquals(true, startupLog.get("otlp_metrics_export_enabled")); - assertEquals(true, startupLog.get("otlp_logs_export_enabled")); + assertTrue(flag(startupLog, "otlp_traces_export_enabled")); + assertTrue(flag(startupLog, "otlp_metrics_export_enabled")); + assertTrue(flag(startupLog, "otlp_logs_export_enabled")); } @Test - @WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp") - @WithConfig(key = OtlpConfig.METRICS_OTEL_EXPORTER, value = "otlp") - @WithConfig(key = OtlpConfig.LOGS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = TRACE_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = METRICS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = LOGS_OTEL_EXPORTER, value = "otlp") void metricsAndLogsRequireOtelSignalEnabled() throws IOException { - // The OTLP exporter is selected for every signal, but the metrics and logs OTel signals are - // left disabled, so only trace export should be reported as enabled. - Map startupLog = startupLog(Config.get()); + Map startupLog = startupLog(); - assertEquals(true, startupLog.get("otlp_traces_export_enabled")); - assertEquals(false, startupLog.get("otlp_metrics_export_enabled")); - assertEquals(false, startupLog.get("otlp_logs_export_enabled")); + assertTrue(flag(startupLog, "otlp_traces_export_enabled")); + assertFalse(flag(startupLog, "otlp_metrics_export_enabled")); + assertFalse(flag(startupLog, "otlp_logs_export_enabled")); } @Test - @WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp") - @WithConfig(key = TracerConfig.WRITER_TYPE, value = "DDAgentWriter") + @WithConfig(key = TRACE_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = WRITER_TYPE, value = DD_AGENT_WRITER_TYPE) void tracesNotExportedWhenWriterTypeOverridesOtlpExporter() throws IOException { - // The OTLP trace exporter is selected, but an explicit dd.writer.type override wins in - // WriterFactory, so the effective writer is the DDAgentWriter and traces are not exported over - // OTLP. - Map startupLog = startupLog(Config.get()); + assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = WRITER_TYPE, value = "MultiWriter:OtlpWriter,DDAgentWriter") + void tracesExportedWhenMultiWriterIncludesOtlpWriter() throws IOException { + assertTrue(flag(startupLog(), "otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = WRITER_TYPE, value = "MultiWriter:DDAgentWriter,MultiWriter:OtlpWriter") + void tracesExportedWhenMultiWriterPrefixRepeats() throws IOException { + assertTrue(flag(startupLog(), "otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = WRITER_TYPE, value = "MultiWriter:LoggingWriter,DDAgentWriter") + void tracesNotExportedWhenMultiWriterExcludesOtlpWriter() throws IOException { + assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = WRITER_TYPE, value = "MultiWriter: OtlpWriter") + void tracesNotExportedWhenMultiWriterSubTypeIsPadded() throws IOException { + assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = WRITER_TYPE, value = "MultiWriter:OtlpWriterExtra") + void tracesNotExportedWhenMultiWriterSubTypeOnlyPrefixesOtlpWriter() throws IOException { + assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); + } + + @Test + @WithConfig(key = WRITER_TYPE, value = "DDAgentWriter,OtlpWriter") + void tracesNotExportedWhenCommaSeparatedWithoutMultiWriterPrefix() throws IOException { + assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); + } - assertEquals(false, startupLog.get("otlp_traces_export_enabled")); + @Test + @WithConfig(key = WRITER_TYPE, value = "TraceStructureWriter:/tmp/out,OtlpWriter") + void tracesNotExportedWhenTraceStructureWriterTakesPrecedence() throws IOException { + assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); } @Test - @WithConfig(key = OtlpConfig.OTEL_TRACES_SPAN_METRICS_ENABLED, value = "true") + @WithConfig(key = OTEL_TRACES_SPAN_METRICS_ENABLED, value = "true") void metricsExportedWhenSpanMetricsEnabled() throws IOException { - // Span metrics are exported over OTLP via OtlpStatsMetricWriter whenever span metrics are - // enabled, independently of the OTel metrics signal, so metrics export should be reported. - Map startupLog = startupLog(Config.get()); + assertTrue(flag(startupLog(), "otlp_metrics_export_enabled")); + } - assertEquals(true, startupLog.get("otlp_metrics_export_enabled")); + @Test + @WithConfig(key = METRICS_OTEL_ENABLED, value = "true") + @WithConfig(key = METRICS_OTEL_EXPORTER, value = "otlp") + @WithConfig(key = OTEL_TRACES_SPAN_METRICS_ENABLED, value = "false") + void metricsExportedWhenOtelMetricsSignalEnabledWithoutSpanMetrics() throws IOException { + assertTrue(flag(startupLog(), "otlp_metrics_export_enabled")); } @SuppressWarnings("unchecked") - private static Map startupLog(Config config) throws IOException { + private static Map startupLog() throws IOException { String json = - new Moshi.Builder().add(new StatusLogger()).build().adapter(Config.class).toJson(config); + new Moshi.Builder() + .add(new StatusLogger()) + .build() + .adapter(Config.class) + .toJson(Config.get()); return (Map) new Moshi.Builder().build().adapter(Object.class).fromJson(json); } + + private static boolean flag(Map startupLog, String name) { + Object value = startupLog.get(name); + assertTrue(value instanceof Boolean, name + " should be a boolean, was " + value); + return (Boolean) value; + } } diff --git a/internal-api/src/main/java/datadog/trace/api/Config.java b/internal-api/src/main/java/datadog/trace/api/Config.java index 7d6df22df1c..8ee70319631 100644 --- a/internal-api/src/main/java/datadog/trace/api/Config.java +++ b/internal-api/src/main/java/datadog/trace/api/Config.java @@ -727,6 +727,7 @@ import static datadog.trace.api.config.TracerConfig.WRITER_LINKS_INJECT; import static datadog.trace.api.config.TracerConfig.WRITER_TYPE; import static datadog.trace.api.telemetry.LogCollector.SEND_TELEMETRY; +import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.MULTI_WRITER_TYPE; import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.OTLP_WRITER_TYPE; import static datadog.trace.util.CollectionUtils.tryMakeImmutableList; import static datadog.trace.util.CollectionUtils.tryMakeImmutableSet; @@ -828,6 +829,9 @@ public class Config { private static final int MAX_CODE_COVERAGE_FLAGS = 32; private static final Pattern COLON = Pattern.compile(":"); + private static final Pattern COMMA = Pattern.compile(","); + private static final Pattern MULTI_WRITER_PREFIX = + Pattern.compile(MULTI_WRITER_TYPE + ":", Pattern.LITERAL); // Historical conflating-Batch size; used to translate TRACER_METRICS_MAX_PENDING (configured in // legacy batch units) into the new per-SpanSnapshot inbox capacity. @@ -5577,6 +5581,10 @@ public boolean isLogsOtlpExporterEnabled() { return "otlp".equalsIgnoreCase(logsOtelExporter); } + public boolean isOtlpLogsExportEnabled() { + return isLogsOtelEnabled() && isLogsOtlpExporterEnabled(); + } + public int getLogsOtelInterval() { return logsOtelInterval; } @@ -5621,6 +5629,11 @@ public boolean isMetricsOtlpExporterEnabled() { return "otlp".equalsIgnoreCase(metricsOtelExporter); } + public boolean isOtlpMetricsExportEnabled() { + return (isMetricsOtelEnabled() && isMetricsOtlpExporterEnabled()) + || isOtelTracesSpanMetricsEnabled(); + } + public boolean isMetricsOtelExperimentalEnabled() { return metricsOtelExperimentalEnabled; } @@ -5677,6 +5690,19 @@ public boolean isTraceOtlpExporterEnabled() { return "otlp".equalsIgnoreCase(traceOtelExporter); } + public boolean isOtlpTracesExportEnabled() { + if (!writerType.startsWith(MULTI_WRITER_TYPE)) { + return OTLP_WRITER_TYPE.equals(writerType); + } + String multiWriterConfig = MULTI_WRITER_PREFIX.matcher(writerType).replaceAll(""); + for (String subWriterType : COMMA.split(multiWriterConfig)) { + if (OTLP_WRITER_TYPE.equals(subWriterType)) { + return true; + } + } + return false; + } + public String getOtlpTracesEndpoint() { return otlpTracesEndpoint; }