chore(internal): share the entry-point trust policy across the split packages #22195
<a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40git.commit.sha%3A0a88591280d26ab96bdceb80b1f348912e4e713d&referrer=pr-comment&start=1796137809000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok-light.svg" alt="Pipelines" align="center" /></picture></a> <a target='_blank' href='https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest+%40git.commit.sha%3Aa15ac3770f1ff5e671324ec4d1333c8982cccaed&referrer=pr-comment&start=1796137809000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-ok-light.svg" alt="Tests" align="center" /></picture></a>
<details><summary><b>🎉 All green!</b></summary>
🧪 All tests passed
❄️ No new flaky tests detected
</details>
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: 0a88591 | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RkLXRyYWNlLXB5LzIyMTk1?referrer=pr-comment">View more details</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"af32c987c9ab69f2019b043fdb29a8be58241660","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-12-01T11:59:33.257663Z">2026-12-01T11:59:33.257663Z</relative-time> | af32c98 | New commits |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your 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.
</details>
</details>
Benchmarks
Benchmark execution time: 2026-12-01 16:11:30
Comparing candidate commit 0a88591280d26ab96bdceb80b1f348912e4e713d in PR branch gnufede/package-split-entry-point-trust with baseline commit 498511e8e1f87b07f4925fa85abb7cb85619e171 in branch main.
Found 1 performance improvements and 0 performance regressions! Performance is the same for 620 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.
<details>
<summary><h3>Explanation</h3></summary>
This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:
🟩 = significantly better candidate vs. baseline
🟥 = significantly worse candidate vs. baseline
We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.
If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.
Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.
<details>
<summary><h4>More details about the CI and significant changes</h4></summary>
You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.
CIs of the difference of means are often centered around 0%, because often changes are not that big:
---------------------------------(------|---^--------)-------------------------------->
-0.6% 0% 0.3% +1.2%
| | |
lower bound of the CI --' | |
sample mean (center of the CI) -------------' |
upper bound of the CI ----------------------'
As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).
For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:
----------------------------------------|---------|---(---------^---------)---------->
0% 1% 1.3% 2.2% 3.1%
| | | |
significant impact threshold --------------' | | |
lower bound of CI --------------' | |
sample mean (center of the CI) --------------------------' |
upper bound of CI ----------------------------------'
</details>
</details>
scenario:rand-rand64bits
execution_time [-15.074ns; -11.903ns] or [-12.468%; -9.846%]<details>
<summary><h3>Unstable benchmarks</h3></summary>
These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.
scenario:coreapiscenario-context_with_data_listeners
execution_time [-638.943ns; +833.992ns] or [-6.023%; +7.862%]scenario:coreapiscenario-core_dispatch_1_listener
execution_time [-42.429ns; +35.602ns] or [-6.612%; +5.548%]scenario:coreapiscenario-core_dispatch_50_listeners
execution_time [-1752.071ns; +2058.334ns] or [-8.858%; +10.406%]scenario:coreapiscenario-core_dispatch_exception_listeners
execution_time [-2225.106ns; +1470.885ns] or [-11.332%; +7.491%]scenario:coreapiscenario-core_dispatch_listeners
execution_time [-351.515ns; +406.584ns] or [-8.335%; +9.640%]scenario:coreapiscenario-core_dispatch_no_args_listeners
execution_time [-215.053ns; +239.372ns] or [-8.128%; +9.047%]scenario:coreapiscenario-core_dispatch_with_results_1_listener
execution_time [-79.305ns; +100.443ns] or [-5.839%; +7.396%]scenario:coreapiscenario-core_dispatch_with_results_50_listeners
execution_time [-5651.769ns; +3663.233ns] or [-11.465%; +7.431%]scenario:coreapiscenario-core_dispatch_with_results_listeners
execution_time [-1155.790ns; +761.166ns] or [-11.055%; +7.280%]scenario:packagesupdateimporteddependencies-import_many_stdlib_cached
execution_time [-60.212µs; +51.164µs] or [-10.268%; +8.725%]</details>
<details>
<summary><h3>Known flaky benchmarks</h3></summary>
These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.
Known flaky benchmarks without significant changes:
</details>
<sub><sub>!P1 Badge</sub></sub> Provide benchmark coverage for the startup-path change
The supplied validation lists correctness tests but no startup benchmark results. This trust check runs for every discovered product during bootstrap, and the new helper call adds another metadata read and parse per check. Run the run-benchmarks skill and report a baseline comparison for startup/import latency, as required for startup-sensitive changes.
AGENTS.md reference: AGENTS.md:L16-L18
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<sub><sub>!P1 Badge</sub></sub> Use plain prose in unrendered helper docstrings
These helpers are not exposed through Sphinx, so formatting parameter names such as dist with reStructuredText double backticks violates the repository's explicit convention for unrendered docstrings. Remove that formatting here and in the corresponding helper docstrings at lines 75 and 80.
AGENTS.md reference: AGENTS.md:L89-L90
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<sub><sub>!P2 Badge</sub></sub> Reuse the distribution name already read for trust checks
On Python 3.10+, the preceding line already obtains dist.metadata["Name"], but distribution_name(dist) accesses dist.metadata again. The stdlib Distribution.metadata property is uncached and reads and parses the metadata file on each access, so this adds a redundant file read and email-metadata parse for every product checked during bootstrap. Normalize the name already fetched instead of retrieving the metadata twice.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15c25ceed5
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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".
</details>
<details>
<summary>More details</summary>
The shared trust helper checks normalized distribution names and dotted module prefixes, preserving rejection of lookalike namespaces while accepting the listed split packages. Static review identified no actionable defect.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 15c25ce</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=31dedad6-5313-4b05-b2ca-f20b384f8eac -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:45a2d7ba50da5b2e1574807823f40b6c38c5458f27a7ee560a9d44ac5ea6b731:bundle -->
Codeowners resolved as
Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.
benchmarks/suitespec.yml @DataDog/apm-core-python
ddtrace/internal/entry_points.py @DataDog/apm-core-python
ddtrace/internal/integration_hooks.py @DataDog/apm-core-python
ddtrace/internal/products.py @DataDog/apm-core-python
ddtrace/internal/utils/entry_points.py @DataDog/apm-core-python
mypy.ini @DataDog/apm-python-guild @DataDog/apm-core-python
tests/internal/test_entry_points.py @DataDog/apm-core-python
tests/internal/test_integration_hooks.py @DataDog/apm-core-python
tests/internal/test_products.py @DataDog/apm-core-python
tests/profiling/test_product.py @DataDog/profiling-python
Dependency direction analysis
⚠️ Existing dependency direction violations
There are 22 dependency direction violations that already exist on the base branch and have not been changed by this PR.
<details><summary>Show existing violations (showing 5 of 22 highest severity)</summary>
ddtrace.internal.tracemethods -×-> ddtrace.trace (internal-core -> product:tracing, score=103)
ddtrace.llmobs._integrations.bedrock_agents -×-> ddtrace.trace (product:llmobs -> product:tracing, score=101)
ddtrace.llmobs._integrations.base -×-> ddtrace.trace (product:llmobs -> product:tracing, score=101)
ddtrace.internal.span_bus -×-> ddtrace._trace.span (internal-core -> product:tracing, score=35)
ddtrace.llmobs._llmobs -×-> ddtrace._trace.span (product:llmobs -> product:tracing, score=33)
</details>
To see all violations, download thelayers-base.jsonandlayers-pr.jsonartifacts from this CI job and run:
> uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json >
<sub><sub>!P2 Badge</sub></sub> Update the profiling test to unpack entry-point pairs
The new return shape breaks the unchanged consumer in tests/profiling/test_product.py:1093: test_loading_product_does_not_import_profiler still iterates these results as entry points and evaluates ep.name. Each result is now a tuple, so the test raises AttributeError: 'tuple' object has no attribute 'name' before checking profiler lazy-loading behavior. Update that consumer to unpack (ep, dist), as the other callers now do.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af32c987c9
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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".
</details>
Approved these changes.
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:67c4ea4b6f138533ab03152dc29378cf73bbf57b9f0b722364a8315e2d85401b:inline-0 -->
<sub><sub>!P1</sub></sub> Update the remaining profiler test for paired entry points
<!-- autotest-finding-meta prod_data_type=none finding_id=b79d67f7-ef43-4a14-8a5e-97fb70a96fa4 prod_effect=static -->
Returning (entry_point, distribution) tuples breaks tests/profiling/test_product.py::test_loading_product_does_not_import_profiler: its unchanged comprehension accesses ep.name on each tuple, raising AttributeError before checking profiler imports. Update that comprehension to unpack (ep, _) so the existing test can run.
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/31dedad6-5313-4b05-b2ca-f20b384f8eac?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
The PR centralizes entry-point trust policy and accepts ddtrace-internal providers.
Earlier updates restricted the allowlists and handled missing distribution names safely.
The latest commit enforces distribution checks on Python 3.9 by pairing entry points with distributions.
One issue remains: an unchanged profiler test expects bare entry points and will raise AttributeError.
Runtime tests and benchmarks were not run.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit af32c98</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=31dedad6-5313-4b05-b2ca-f20b384f8eac -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:67c4ea4b6f138533ab03152dc29378cf73bbf57b9f0b722364a8315e2d85401b:bundle -->
<details>
<summary>More details</summary>
Product and integration-hook loading preserve both distribution and module-namespace checks, including on Python 3.9 where entry points lack a dist attribute. The static reviewer identified no actionable introduced defects.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit d9eb26b</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=f99727ef-b190-4695-a757-4fa641baafef -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:27eda6910887b5a442185313c96e7652d63f698213180f07cc3bdb07252fbcc4:bundle -->
Should this be owned by ddtrace-internal package?
Approved these changes.
Should this be owned by ddtrace-internal package?
@brettlangdon yes, it should end up there, but not in this PR, moving it now would block the stack on a ddtrace-internal release and #22140 still edits these files
Approved these changes.
Should we just look for _ddtrace?
Seems... Wary, but we also have to keep updating this every time we publish a new package?
TODO: add CI check that this list is up to date with modules/dists defined in datadog-apm-python?
Comment referencing session not actual reason this is here?
I would rather fail on the conservative side, than trusting anyone publishing a package starting by _ddtrace inadvertently.
Yeah, I agree with the CI check 👍
Approved these changes.
<details>
<summary>More details</summary>
The shared policy requires both an allowlisted distribution and a first-party module namespace for product plugins and integration hooks. The completed static review identified no actionable defect; runtime behavior was not exercised.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 0a88591</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=f67ec342-f064-42d2-92e4-dad9945cca6f -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:0a8102a10ea5d566ee98e75b775ddc6e75469c48e49360847fcbfa6026198876:bundle -->
follow-up PR: https://github.com/DataDog/dd-trace-py/pull/22229
juanjux
gnufede
Description
Split out of #22130, which now stacks on it; #22139 and #22140 stack on top.
The split packages (
ddtrace-internal,ddtrace-native,ddtrace-coverage,ddtrace-testing, ...) declare entry points thatddtraceloads when it's imported. Every internal entry-point group needs the same answer to "which distribution and module may provide this", so this PR puts that answer in one place:ddtrace/internal/utils/entry_points.py(new, stdlib-only, Python 3.9-safe):-
entry_points_with_distributions(group)pairs each entry point with the distribution that declares it.-
FIRST_PARTY_DISTRIBUTIONS/FIRST_PARTY_MODULE_PREFIXESare the first-party allowlists. Names are PEP 503-normalized, and the prefixes end with a dot, soddtrace_evildoesn't matchddtrace..-
is_trusted_entry_point()checks both the distribution and the module path.-
first_party_entry_points(group)warns about and skips everything else.ddtrace/internal/entry_points.py: product plugins are checked against those allowlists. Before, onlyddtrace/ddtrace-serverlessunderddtrace.were accepted.Customer impact
None today. Product plugins from the first-party split packages are now accepted, but none of those packages ships yet. Third-party and lookalike plugins are still refused, as before.
Testing
tests/internal/test_entry_points.py: the lookup on 3.9 and 3.10+, normalization, trusted and untrusted distribution/module pairs, lookalike prefixes, and malformed metadata.tests/internal/test_products.py: a product fromddtrace-internalunder_ddtrace_internal.now loads. The existing untrusted and lookalike tests (evil,ddtrace-evil) still pass.Risks
Low. This widens which distributions may provide product plugins, but only to first-party names. Of those names, only
ddtrace-internalis registered on PyPI today. The allowlist prevents accidents; it isn't a defence against an attacker who can install packages.Additional Notes
The policy's other users are the supported-configurations registry (#22130), the library identity (#22139) and the telemetry providers (#22140).