Repository navigation
chore(coverage): add coverage import data opt-out - #21405
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
Conversation
Per-test coverage reports are augmented with the import-time coverage of the transitive import closure of the files each test touches. On large first-party codebases this is a fixed per-test cost that scales with repo size rather than test work, dominating per-test duration. Add _DD_COVERAGE_INCLUDE_IMPORT_DATA (default true) to opt out of that augmentation in both the instrumented-mode context expansion and the CI Visibility per-test report path. Import-time coverage collection itself keeps running: only per-test reporting skips the augmentation. The variable is private on purpose: opting out degrades test skipping correctness, since changes to code that a test imports but does not execute may no longer select that test. A warning is logged once when the opt-out is active.
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 996fc21 | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-11-24 15:32:29 Comparing candidate commit 996fc21 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 635 metrics, 11 unstable metrics, 1 flaky benchmarks without significant changes.
|
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb270f8d80
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
More details
The opt-out preserves import-time collection and suppresses its addition to reported coverage. Runtime behavior remains unverified because the reviewer’s test attempt stopped during native dependency compilation.
🤖 Bits Code Review · Commit cb270f8
The once-per-process opt-out warning only fired from InstrumentedCoverage.expand_context_lines/files, which are reached via CollectInContext.get_covered_lines()/get_covered_file_paths(). The unittest internal-coverage reporter (_DD_USE_INTERNAL_COVERAGE=true) reports through ModuleCodeCollector.report_seen_lines instead and bypassed the expansion hooks, so opting out of import data silently dropped it from per-test coverage reports without the warning the opt-out promises. Move the warning to a shared once-per-process helper in coverage.util and call it from both the expansion hooks and the internal-coverage reporting path, so whichever path reports first logs it exactly once. Addresses the Codex review finding on PR #21405.
## Description **Stacked on #22018** (base `gnufede/package-split-prep`). This freezes every file of the package split's first wave, so nothing can drift between the port and the bridge. It replaces #21967, #21973 and #21990. 33 files are frozen, with hashes of their content after #22018: - **Moving whole to `ddtrace-internal`** (DataDog/datadog-apm-python#77): `utils/cache.py`, `utils/paths.py`, `utils/obfuscation.py`, `utils/time.py`, `compat.py`, `assembly.py`, `logger.py`, `settings/__init__.py`, `settings/env.py`, `module.py`, `bytecode_injection/core.py`. - **Partially moving, frozen whole** so the ported symbols stay identical: - `utils/__init__.py` (`get_argument_value`, `set_argument_value`, `ArgumentError`); - `utils/formats.py` (`asbool`); - `utils/inspection.py` (`resolved_code_origin`); - `bytecode_injection/__init__.py` (`HookType`, `INJECTION_ASSEMBLY`). - **Moving to `ddtrace-coverage`** (DataDog/datadog-apm-python#82): all 18 files under `ddtrace/internal/coverage/`. `src/native` is not frozen here. The native switch is a separate step that waits on the profiling team's agreement on the profiling FFI approach. The bridge PR, landing after `ddtrace-internal` 0.4.0 and `ddtrace-coverage` 0.1.0 are released, replaces these modules with re-exports and removes these entries in the same PR. ## Testing Only `frozen-paths.txt` changes. All 33 hashes were checked against the committed file contents (the same comparison `freeze-check.yml` makes). ## Risks - **Edits are blocked** to these files until the bridge lands. Open PRs that touch them must merge first or rebase afterwards. Earlier we saw `module.py` (#21428, #21448), `coverage/instrumented_mode.py` and `coverage/util.py` (#21405), and older prototype drafts. - **Hash timing.** Hashes are taken from #22018's content. If #22018 changes before merging, they need regenerating. ## Additional Notes None. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
/merge -f --reason "unrelated celery ci job timeout" |
|
View all feedbacks in Devflow UI.
The expected merge time in
Warning This change was merged without running any pre merge CI checks Reason: unrelated celery ci job timeout |
Brings in #21405 (coverage import data opt-out) so the branch is current. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
#21405 modified coverage/util.py and coverage/instrumented_mode.py on main, so their frozen hashes must follow. Main has no freeze entries yet, so updating them within this PR does not lift an existing freeze. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Summary
Adds private
_DD_COVERAGE_INCLUDE_IMPORT_DATA(defaulttrue). Setting it tofalsestops per-test coverage payloads from being augmented with the import-time coverage of each test's transitive import closure — a fixed per-test cost that scales with repo size rather than test work.Validation
tests/coverage/test_import_data_opt_out.py(new): parametrized over_DD_COVERAGE_FILE_LEVEL× the new variable, on py3.10 and py3.12tests/coverageandtests/ci_visibilitysuites pass; lint cleanNotes
changelog/no-changelog).