feat: agentless log submission #22141
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #22141"
general
weight: 0.35
gnufede
Description
DD_AGENTLESS_LOG_SUBMISSION_ENABLEDonly worked inside the Test Optimization pytest plugin. Services that cannot reach a Datadog Agent had to set up the OpenTelemetry logs exporter (extra packages and several settings) to ship logs, while dd-trace-js needs only this variable andDD_API_KEY.In agentless mode (
DD_AGENTLESS_ENABLED=truewithDD_API_KEY), the bootstrap (ddtrace-run/import ddtrace.auto) now submits everyloggingrecord that propagates to the root logger. Records are batched and posted gzipped tohttps://http-intake.logs.<DD_SITE>/api/v2/logs, with service, env, version, hostname, tags, the traceback when present, anddd.trace_id/dd.span_idfrom the logging integration.DD_AGENTLESS_ENABLEDturns log submission on, andDD_AGENTLESS_LOG_SUBMISSION_ENABLEDis its per-product override:falseopts out,truesubmits logs without making anything else agentless (it previously only applied to the Test Optimization plugin). WithoutDD_API_KEY, a warning is logged and nothing is submitted.DD_AGENTLESS_ENABLED=truestart shipping their logs, and so do agentless Test Optimization sessions (called out in the upgrade release note).DD_LOGS_OTEL_ENABLED, the global switch leaves logs to OpenTelemetry (which then exports them agentlessly), in services and in the Test Optimization plugin alike; an explicitDD_AGENTLESS_LOG_SUBMISSION_ENABLED=truewins and turns OpenTelemetry log export off with a startup warning, once the API key and intake URL are known to be valid.logging.Logger.callHandlers, solastResortstderr output,basicConfig()anddictConfig/fileConfigbehave as without the tracer. Records are not modified either: tracebacks are formatted on a copy, so the application's own exception formatting (for example redaction) is unaffected.ddtrace-run pytest, the plugin turns APM submission off before conftests load and discards anything buffered; test logs go only through the plugin, as before.multiprocessingworkers finish normally (they leave throughos._exit()), within one 1s deadline, covering encoding as well as sending, so a slow or unreachable intake or a large backlog can't hold up the exit. Nothing runs from signal handlers: a process ended by a signal,os._exit()orPool.terminate()(with Pool()) loses unsent records, as documented, rather than delaying its shutdown or the tracer's. Forked children don't resend the parent's buffer.LLMObs.enable(service=...)).DD_AGENTLESS_LOG_SUBMISSION_URLto override the intake URL, mainly for testing (dd-trace-js has it too).Stacked on #22182 (base
gnufede/log-intake-shared), which adds the shared, tracer-independent logs-intake writer and handler (ddtrace.internal.log_intake) and moves Test Optimization and LLMObs onto it. This PR only adds the tracer-side wiring (ddtrace.internal.logs) and a smallddtrace.internal.settings._log_submissionmodule that decides whether submission applies, so the Test Optimization plugin uses the same rule without importing the tracer.Customer impact
Services without a reachable Datadog Agent get their Python logs shipped by the same
DD_AGENTLESS_ENABLED=trueandDD_API_KEYthat make the rest of the SDK agentless, as in dd-trace-js, instead of configuring the OpenTelemetry logs exporter.DD_AGENTLESS_LOG_SUBMISSION_ENABLED=falseopts out. Test Optimization logs now include tracebacks. Release notes are included.Testing
tests/internal/test_logs.py(new) covers the writer (batching, limits, UTF-8 encoding, errors), the handler payload, the startup warnings, and end-to-endddtrace-runruns against a local intake for:- trace correlation;
- console output and logging reconfiguration;
- forks and
multiprocessingworkers, includingPoolwithclose()/join()and module cloning;- an intake that never responds: SIGTERM exits as fast and with the same status as with the feature off, and a normal exit is delayed by at most the 1s deadline.
DDTestLogsHandler, and a pytest-plugin test that APM submission is off during the session and drops pre-session records, with and without agentless mode.tests/llmobs/test_logger.pyforV2LogWriter.ddtrace.testing.logsdoes not loadddtrace.internal.logs, and another that the tracer-freeDD_LOGS_OTEL_ENABLEDresolution matches the tracer's configuration.mainfor this split; its tests have not been re-run locally since, so CI is their first run.tests/internal/suite, the LLMObs logger tests and the Test Optimization log tests;tests/internal/test_logs.pyalso on 3.14.scripts/lint checksand the dependency-direction and circular-import checks pass.callHandlerswrapper, a walk up the logger's parents, and one buffered append.Risks
DD_AGENTLESS_ENABLED=true, orDD_AGENTLESS_LOG_SUBMISSION_ENABLED(for example globally in CI), start shipping logs; agentless Test Optimization sessions start submitting test logs.logging.Logger.callHandlersis patched process-wide while enabled. ALoggersubclass that overrides it without calling the base method is not captured.ddtrace-run pytest, records logged beforepytest_load_initial_conftestsare discarded; if that takes over 5s, they could be sent as APM logs.Additional Notes
propagate=False, and loguru.os._exit()(for example a rawos.fork()child), byPool.terminate()(useclose()/join()), or by a crash.DD_LOGS_INJECTION(on by default).