Repository navigation
Conversation
A loader shared by several modules (e.g. a zipimporter) had get_code wrapped once, capturing the first module and its transformers; the guard against re-wrapping then kept later imports bound to them, so transforms received the wrong module. Re-wrap the original get_code on every exec_module so the wrapper is bound to the module being executed, which still prevents wrappers from stacking on reloads. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Modules imported through a loader shared by several modules (for example a zipimporter) could be transformed with the wrong module, which users of zip applications or bundled deployments can hit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
module.py moves to ddtrace-internal in the package split. Freezing it once the shared loader fix landed keeps the ported copy from drifting. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
BenchmarksBenchmark execution time: 2026-11-26 17:40:24 Comparing candidate commit 3745405 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 604 metrics, 10 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: 3745405a21
ℹ️ 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".
| _get_code = getattr(_get_code, "_dd_original_get_code", _get_code) | ||
| if _get_code is not None: |
There was a problem hiding this comment.
Add the required startup benchmark coverage
This changes the watched-import startup path and allocates and binds a fresh wrapper whenever a loader is reused, but the supplied validation reports correctness tests and commit hooks without benchmark results. The repository explicitly requires benchmarks for startup-sensitive changes. Run the run-benchmarks skill comparing the parent and this commit for startup and shared-loader imports, and record the results before accepting the additional import-time work.
AGENTS.md reference: AGENTS.md:L16-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
More details
Saving and rewrapping the original get_code binds transformations to each imported module while preventing wrappers from accumulating across reloads. The specialist’s static review returned no actionable findings.
🤖 Bits Code Review · Commit 3745405
Description
Part of replacing #22018 with smaller PRs on main. Split out at the reviewer's request:
#22018 (comment)
A loader shared by several modules (e.g. a
zipimporter) hadget_codewrapped once, capturing the first module and its transformers. The guard against re-wrapping then kept later imports bound to them, so transforms received the wrong module.exec_modulenow re-wraps the originalget_codeon every call, so the wrapper is bound to the module being executed, and wrappers still do not stack onimportlib.reload().Release note: yes.
ModuleWatchdogbacks every import hook, and zip applications or bundled deployments can hit this, so it is a customer-visiblefix(internal).Also freezes
ddtrace/internal/module.pyinfrozen-paths.txt(it moves to ddtrace-internal). It is frozen here, not in the utils prep PR, so that PR does not depend on this one. The hash equals the one frozen in #22018.Testing
New
tests/internal/test_module_shared_loader.py; rantests/internal(3.12, internal suite): 3357 passed. Commit hooks passed.CODEOWNERS pulled in: @DataDog/debugger-python, @DataDog/apm-core-python (module.py, tests/internal), @DataDog/apm-python (releasenotes), @DataDog/apm-core-python (frozen-paths.txt).
Risks
Low: only the
get_codewrapping in_ImportHookChainedLoader.exec_module.🤖 Generated with Claude Code