-
Notifications
You must be signed in to change notification settings - Fork 348
Report OTLP export status in tracer startup log #12062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gh-worker-dd-mergequeue-cf854d
merged 8 commits into
master
from
brian.marks/otlp-export-startup-log
Jul 31, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a4287c5
Add OTLP export flags to tracer startup diagnostic log
bm1549 6d1065b
Base OTLP export flags on effective writer and span metrics
bm1549 070e7d8
Derive OTLP export flags in Config and honor MultiWriter
bm1549 4db8aa4
Drop pre-compiled regexes from isOtlpTracesExportEnabled
bm1549 9690f94
Update internal-api/src/main/java/datadog/trace/api/Config.java
bm1549 61ce2a0
Update internal-api/src/main/java/datadog/trace/api/Config.java
bm1549 4cdbd77
Use flat MultiWriter parsing for OTLP status
bm1549 c884de5
Merge branch 'master' into brian.marks/otlp-export-startup-log
bm1549 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
dd-trace-core/src/test/java/datadog/trace/core/StatusLoggerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| package datadog.trace.core; | ||
|
|
||
| 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.json.JsonMapper; | ||
| import datadog.trace.api.Config; | ||
| 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; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.Timeout; | ||
|
|
||
| @Timeout(value = 10, unit = TimeUnit.SECONDS) | ||
| public class StatusLoggerTest extends DDJavaSpecification { | ||
|
|
||
| @Test | ||
| void otlpExportDisabledByDefault() throws IOException { | ||
| Map<String, Object> startupLog = startupLog(); | ||
|
|
||
| assertFalse(flag(startupLog, "otlp_traces_export_enabled")); | ||
| assertFalse(flag(startupLog, "otlp_metrics_export_enabled")); | ||
| assertFalse(flag(startupLog, "otlp_logs_export_enabled")); | ||
| } | ||
|
|
||
| @Test | ||
| @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<String, Object> startupLog = startupLog(); | ||
|
|
||
| assertTrue(flag(startupLog, "otlp_traces_export_enabled")); | ||
| assertTrue(flag(startupLog, "otlp_metrics_export_enabled")); | ||
| assertTrue(flag(startupLog, "otlp_logs_export_enabled")); | ||
| } | ||
|
|
||
| @Test | ||
| @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 { | ||
| Map<String, Object> startupLog = startupLog(); | ||
|
|
||
| assertTrue(flag(startupLog, "otlp_traces_export_enabled")); | ||
| assertFalse(flag(startupLog, "otlp_metrics_export_enabled")); | ||
| assertFalse(flag(startupLog, "otlp_logs_export_enabled")); | ||
| } | ||
|
|
||
| @Test | ||
| @WithConfig(key = TRACE_OTEL_EXPORTER, value = "otlp") | ||
| @WithConfig(key = WRITER_TYPE, value = DD_AGENT_WRITER_TYPE) | ||
| void tracesNotExportedWhenWriterTypeOverridesOtlpExporter() throws IOException { | ||
| 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: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")); | ||
| } | ||
|
|
||
| @Test | ||
| @WithConfig(key = WRITER_TYPE, value = "TraceStructureWriter:/tmp/out,OtlpWriter") | ||
| void tracesNotExportedWhenTraceStructureWriterTakesPrecedence() throws IOException { | ||
| assertFalse(flag(startupLog(), "otlp_traces_export_enabled")); | ||
| } | ||
|
|
||
| @Test | ||
| @WithConfig(key = OTEL_TRACES_SPAN_METRICS_ENABLED, value = "true") | ||
| void metricsExportedWhenSpanMetricsEnabled() throws IOException { | ||
| assertTrue(flag(startupLog(), "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")); | ||
| } | ||
|
|
||
| private static Map<String, Object> startupLog() throws IOException { | ||
| String json = | ||
| new Moshi.Builder() | ||
| .add(new StatusLogger()) | ||
| .build() | ||
| .adapter(Config.class) | ||
| .toJson(Config.get()); | ||
| return JsonMapper.fromJsonToMap(json); | ||
| } | ||
|
|
||
| private static boolean flag(Map<String, Object> startupLog, String name) { | ||
| Object value = startupLog.get(name); | ||
| assertTrue(value instanceof Boolean, name + " should be a boolean, was " + value); | ||
| return (Boolean) value; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.