feat: report OTLP export status in startup log - #19265
Draft
bm1549 wants to merge 1 commit into
Draft
Conversation
This was referenced Jul 24, 2026
Contributor
🎉 All green!🧪 All tests passed 🔄 Datadog auto-retried 1 job - 1 passed on retry 🔗 Commit SHA: 8beb3e0 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-25 03:11:10 Comparing candidate commit 8beb3e0 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 612 metrics, 10 unstable metrics. scenario:iastaspectsospath-ospathbasename_aspect
scenario:span-start
scenario:tracer-small
|
bm1549
force-pushed
the
brian.marks/otlp-export-startup-log
branch
from
July 24, 2026 21:30
e09dd49 to
0025fca
Compare
Codeowners resolved as |
Circular import analysis
|
Add three boolean fields to the tracer's startup diagnostic log
("DATADOG TRACER CONFIGURATION") indicating whether each telemetry
signal is exported over OTLP:
- otlp_traces_export_enabled: reflects agent_config.trace_otlp_export_enabled
(opt-in via OTEL_TRACES_EXPORTER=otlp; export is routed through
libdatadog's native OTLP trace exporter)
- otlp_metrics_export_enabled: reflects config._otel_metrics_enabled
- otlp_logs_export_enabled: reflects config._otel_logs_enabled
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bm1549
force-pushed
the
brian.marks/otlp-export-startup-log
branch
from
July 25, 2026 02:40
0025fca to
8beb3e0
Compare
gh-worker-dd-mergequeue-cf854d Bot
pushed a commit
that referenced
this pull request
Jul 27, 2026
## Description When `DD_LOGS_OTEL_ENABLED=true`, the OTLP logs pipeline attaches an OpenTelemetry `LoggingHandler` to the Python root logger. ddtrace's own loggers (`ddtrace.*`) and the OpenTelemetry exporter's loggers (`opentelemetry.*`) propagate to root, so the handler captured the tracer's own log records: the per-export debug line and the exporter's export-failure warnings/errors. Exporting those records emits more log records, which were captured and exported again. The result is a self-amplifying export loop. This happens whenever those records reach the effective log level: with `DD_TRACE_DEBUG=true` (the per-export debug line), or on export failures (warnings/errors at the default level). The fix attaches a self-telemetry exclusion filter to the OTLP `LoggingHandler` that drops records whose logger name is in the `ddtrace` or `opentelemetry` namespaces. Matching is exact-or-dotted-prefix (`ddtrace` / `ddtrace.*`, `opentelemetry` / `opentelemetry.*`), so application loggers such as `ddtrace_myapp` are not affected. The filter is attached only to the handler ddtrace itself installs; application-configured handlers are not modified. Application logs are still captured and exported. This was discovered during cross-tracer startup-log work. It is an independent, pre-existing bug, so it ships on its own branch. ## Testing Adds `tests/opentelemetry/test_logs.py::test_otel_logs_exporter_excludes_self_telemetry`. With `DD_LOGS_OTEL_ENABLED=true`, it emits a `ddtrace.*` record, an `opentelemetry.*` record, and an application record, flushes the exporter to a mock gRPC log service, and asserts the application record is exported while the two self-telemetry records are not. The test fails without the fix and passes with it. It runs across the OpenTelemetry versions already covered by the `opentelemetry` test venv. ## Risks Low. The change only adds a logging filter to the handler ddtrace creates. Records from the `ddtrace` and `opentelemetry` logger namespaces are no longer exported through this pipeline; application logs are unchanged. The filter binds to the handler instance, so it persists across `logging.basicConfig` reconfiguration, which is the reconfiguration API the OpenTelemetry SDK patches to re-add the same handler instance (`dictConfig`/`fileConfig` are not patched by the SDK). ## Additional Notes Includes a reno release note. No configuration or public API changes. --- ### Context Independent, pre-existing bug surfaced while adding OTLP export-status fields to the tracer startup log across dd-trace-* (the Python system-test for the logs field hung on this loop). Related: - Startup-log feature (dd-trace-py): #19265 - system-tests coverage that surfaced it: DataDog/system-tests#7376 Co-authored-by: brian.marks <brian.marks@datadoghq.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds three boolean fields to the tracer's startup diagnostic log ("DATADOG TRACER CONFIGURATION"), emitted from
collect()inddtrace/internal/debug.py:otlp_traces_export_enabled: reflectsagent_config.trace_otlp_export_enabled(OTLP trace export, opt-in viaOTEL_TRACES_EXPORTER=otlp)otlp_metrics_export_enabled: reflectsconfig._otel_metrics_enabledotlp_logs_export_enabled: reflectsconfig._otel_logs_enabledThis makes the OTLP export configuration visible in the startup log, which helps with support and debugging. It is part of a cross-tracer effort, so the JSON keys are identical across the dd-trace-* libraries.
Testing
test_standard_tagsasserts the three keys are present and boolean.test_otlp_export_enabled_fields_defaultruns in a subprocess with the OTLP-related env cleared and asserts all three default toFalse.test_otlp_export_enabled_fields_setruns in a subprocess withOTEL_TRACES_EXPORTER=otlpand the metrics/logs flags enabled, and asserts all three reportTrue.Risks
None. The change only adds fields to an existing diagnostic log. No existing fields or behavior change.
Additional Notes
No release note is needed: this change only adds fields to the tracer's internal startup diagnostic log and does not change customer-facing behavior. The PR carries the
changelog/no-changeloglabel.Related PRs — cross-tracer OTLP startup-log effort