Repository navigation
Conversation
The pytest plugin and the BDD plugin imported ddtrace, and the logging and selenium contrib patches, directly. Move those touchpoints behind lazy helpers in tracer_api/context.py (get_tracer, enable_log_correlation, enable_selenium_integration), next to the existing trace filter and patch-all helpers. No behavior change. It makes tracer_api the single seam between test optimization and the tracer, so the plugin can later be extracted into its own package with the tracer integration injected by dd-trace-py. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> (cherry picked from commit c4a3ca2)
Every other ddtrace.testing module logs through logging.getLogger; the xdist helpers were the exception, importing ddtrace.internal.logger. Its extras (product rate limiting, ddtrace.* level lookup) do not apply to this module's records, so the stdlib logger is equivalent here and drops one more ddtrace internal from the plugin. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> (cherry picked from commit 9010a00)
With tracer integration off, a pytest session must not make ddtrace.testing import the tracer, _monkey or the logging/selenium contrib. sys.modules cannot show this in-tree, since importing ddtrace.testing runs ddtrace/__init__, so the test records imports by importer. Positive controls cover tracer integration on and --ddtrace-patch-all. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> (cherry picked from commit 0e2d7fb)
The pytest plugin imported get_relative_path and get_source_lines_for_test_method from ci_visibility.utils, which imports ddtrace, the coverage contrib and the legacy CI visibility package, so that one import loaded the tracer and 32 ci_visibility modules. Both helpers only use the standard library and utils.paths. They move, with the line-counting helper they use, into ddtrace.testing.internal.source_info, which moves with test optimization. The legacy CI visibility code imports them from there, and their tests move to tests/testing. The plugin still loads the tracer through ddtrace.contrib.internal.coverage, whose home is not decided yet. The new tests check that source_info loads no tracer modules and that the plugin no longer loads ci_visibility. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 163bdb4) (cherry picked from commit 618a20f)
Every `ddtrace.contrib.*` import runs ddtrace/contrib/__init__.py, which imports the trace handlers and subscribers, so the pytest plugin loaded the tracer just to reach the coverage.py integration's helpers. All of that code is test optimization's: the pytest plugin, the xdist plugin, tracer_api.coverage, ci_visibility and the unittest integration are its only users. It is not the line coverage collector (ddtrace-coverage), which knows nothing about coverage.py. The coverage instance state, the start/stop/report functions, the pytest-cov and `coverage run` detection, the LCOV conversion and their constants move to ddtrace/testing/internal/coverage_py/, with git history, and the users import them from there. ddtrace/contrib/internal/coverage/patch.py stays as the thin integration that _monkey and the integration registry expect: patch(), unpatch(), get_version() and _supported_versions(), delegating to the moved patch/unpatch. patch(coverage=True), the docs in its __init__ and coverage.manifest.yaml are unchanged. The COVERAGE_RUN lookup used the tracer's configuration getter, which imports the tracer settings. It now reads the same variable from the env accessor with the same boolean parsing. As the getter also reported it to configuration telemetry and read stable config, that report is gone. test_tracer_isolation now asserts that importing the plugin loads no ddtrace._trace, ddtrace.trace or ddtrace.contrib module. The mypy sections follow the modules, and the tests that patched the old paths use the new ones. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> (cherry picked from commit cd7df69de0142ff67e63733d99ff2ad30d399053) (cherry picked from commit 21dc684)
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
…-libraries ddtrace/contrib/internal/coverage is already owned by ci-app-libraries, and its logic now lives in ddtrace.testing, but its tests fell under the generic tests/contrib/ rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
Static inspection found that the caller migrations preserve shared coverage state and existing tracer activation behavior. No actionable regression was identified.
🤖 Bits Code Review · Commit b9dee5b
BenchmarksBenchmark execution time: 2026-11-26 16:24:34 Comparing candidate commit b9dee5b in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics.
|
Part of replacing #22018 with smaller PRs on main.
🤖 Generated with Claude Code