Skip to content

chore(package-split): bridge codeowners to the extracted package - #21725

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
mainfrom
gnufede/bridge
Nov 23, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
mainfrom
gnufede/bridge

Conversation

@gnufede

@gnufede gnufede commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Description

ddtrace.internal.codeowners has been extracted to the
datadog-apm-python repository, where it ships in
the ddtrace-internal package as _ddtrace_internal.codeowners. This PR replaces the vendored
implementation in dd-trace-py with a bridge that re-exports the extracted module, leaving a single
source of truth. There is no fallback to the vendored copy — the bridge fails loudly if the
dependency is missing, and the previous implementation remains in git history if a revert is ever
needed.

This is a version bump, not a new dependency. ddtrace already depends on ddtrace-internal;
the extraction originally landed in a separate ddtrace-internal-base distribution, which
datadog-apm-python#69 absorbed back into ddtrace-internal before either was published. So the
pin moves 0.2.0 → 0.3.0 (the release that carries codeowners) and ddtrace-internal-base
disappears from the runtime dependencies, the lint group and both requirements CSVs.

Notes:

  • The package is also pinned in the lint dependency group: mypy runs with --only-group lint,
    and without the installed package ignore_missing_imports = true would silently resolve
    Codeowners to Any for every consumer.
  • CSVs regenerated with scripts/requirements_to_csv.py rather than hand-edited — they are
    CRLF, and editing them as text rewrites every line ending.
  • requirements.csv and lib-injection/sources/requirements.csv are regenerated to include the
    new dependency.

Testing

  • New bridge resolution test in tests/internal/test_codeowners.py asserts the bridge resolves
    to the extracted class.
  • Validated with the internal, ci_visibility::testing, and detect_global_locks suites
    (py3.12), plus scripts/lint checks — all passing.
  • Not ported: the extracted package carries its own test suite in datadog-apm-python.

Risks

  • This PR requires ddtrace-internal 0.3.0 on PyPI; the published 0.2.0 does not contain
    codeowners. CI environment builds resolve strictly from PyPI and will fail until that release
    exists — kept in draft until then. The bump is datadog-apm-python#72.
  • Verified locally against a 0.3.0 wheel built from that bump branch and served through a local
    PEP 503 index, which is enough for the full pre-commit suite (ruff, mypy, codespell, bandit,
    ast-grep, error-log check) to run for real rather than be skipped.
  • Downstream private mirrors / vendored wheelhouses must also mirror the new dependency
    (covered by the release note).

Additional Notes

  • Release note added (upgrade section): installing or upgrading ddtrace now pulls in
    ddtrace-internal-base.

ddtrace.internal.codeowners has been extracted to datadog-apm-python as
_ddtrace_internal_base.codeowners (published as ddtrace-internal-base).
Replace the vendored implementation with a bridge that re-exports the
extracted package, so there is a single source of truth. The bridge fails
loudly if the package is missing; the vendored code remains in git history.

Also pin the package in the lint dependency group: mypy runs with
--only-group lint, and without the installed package
ignore_missing_imports=true would silently degrade Codeowners to Any
downstream (e.g. bdd.py returning-Any).

Verified locally with a wheel built from datadog-apm-python: internal,
ci_visibility::testing, and detect_global_locks suites pass, along with
scripts/lint checks.
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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.

ddtrace/internal/codeowners.py                                          @DataDog/ci-app-libraries
lib-injection/sources/requirements.csv                                  @DataDog/apm-core-python
pyproject.toml                                                          @DataDog/apm-python-guild
releasenotes/notes/codeowners-from-ddtrace-internal-89c41a5421721371.yaml  @DataDog/apm-python
requirements.csv                                                        @DataDog/apm-python-guild
tests/internal/test_codeowners.py                                       @DataDog/ci-app-libraries
tests/requirements_locks/6abbc5115929.txt                               @DataDog/apm-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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.

Show existing violations (showing 5 of 22 highest severity)
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)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8a30f08 | Docs | View more details | Give us feedback!

gnufede added a commit that referenced this pull request Nov 12, 2026
…rkflow skill

Automates the bridge pattern proven for ddtrace.internal.codeowners (#21725)
so the next extractions (forksafe, W3C tracestate, OTel sampling) are
mechanical instead of hand-assembled:

- scripts/package-split make-bridge generates the scaffold: the bridge
  module (alias-form re-exports, required by the repo mypy config
  no_implicit_reexport), the runtime dependency and the lint-group pin
  (mypy resolves the lint group only -- a missing pin silently degrades
  every bridged name to Any), regenerated requirements CSVs, the bridge
  resolution test, and a reno note.
- scripts/lint bridged-modules (also part of scripts/lint checks and
  pre-commit hook 13-check-bridged-modules) fails loudly when any
  coordinated piece is missing: dependency wiring, CSV sync, coverage
  test, and re-export/consumer symbol parity against the extracted
  package.
- the bridge-extracted-module skill and docs/package-split/bridges.md
  tracker encode the full workflow, including pre-publication verification
  through a local PEP 503 index.
The extracted module moved: datadog-apm-python absorbed
ddtrace-internal-base into ddtrace-internal, so the bridge imports
_ddtrace_internal.codeowners and the dependency it needs is one ddtrace
already has, at a newer version.

That makes this a version bump rather than a new dependency:
ddtrace-internal goes from 0.2.0 to 0.3.0, the release that carries
codeowners, and ddtrace-internal-base disappears from the runtime
dependencies, the lint group and both requirements CSVs. The release
note says the same -- mirrors must carry the new version, not a new
distribution.

CSVs regenerated with scripts/requirements_to_csv.py.
@pr-commenter

pr-commenter Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-23 08:54:42

Comparing candidate commit 8a30f08 in PR branch gnufede/bridge with baseline commit 5b7fbe1 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 646 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.

Explanation

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.

More details about the CI and significant changes

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 ----------------------------------'

Unstable benchmarks

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

  • unstable execution_time [-626.837ns; +806.694ns] or [-5.809%; +7.476%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-37.103ns; +37.813ns] or [-5.774%; +5.884%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1948.590ns; +1851.935ns] or [-9.598%; +9.122%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1935.491ns; +1572.182ns] or [-9.918%; +8.057%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-362.011ns; +372.672ns] or [-8.293%; +8.537%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-216.985ns; +225.882ns] or [-7.836%; +8.157%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-97.178ns; +78.147ns] or [-6.959%; +5.596%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-4485.816ns; +4525.228ns] or [-9.176%; +9.257%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-982.518ns; +851.631ns] or [-9.477%; +8.215%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-57.718µs; +53.636µs] or [-9.945%; +9.242%]

Known flaky benchmarks

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:

  • scenario:packagespackageforrootmodulemapping-cache_off

The aws_lambda suite depends on datadog-lambda, which transitively
depends on the released ddtrace, so its environment lock pins the full
transitive closure, including ddtrace-internal. scripts/run-tests
strips the ddtrace pin when installing the locally built ddtrace, but
keeps the ddtrace-internal pin, which must match the local wheel's
requirement. With the bridge pointing at ddtrace-internal 0.3.0, the
stale 0.2.0 pin made the env build unsatisfiable (uv exit 1 for
6abbc5115929, Python 3.15 job).

Same manual bump as 96e3c67 (ddtrace-internal 0.1.0 -> 0.2.0). The pin
will track 0.3.0 again naturally once a released ddtrace that requires
ddtrace-internal 0.3.0 is past the lock cooldown.
@gnufede
gnufede marked this pull request as ready for review November 20, 2026 16:33
@gnufede
gnufede requested review from a team as code owners November 20, 2026 16:33
@gnufede
gnufede requested review from danielsn, juanjux and ncybul and removed request for a team November 20, 2026 16:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T08:21:59.147813Z 8a30f08 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gnufede
gnufede requested a review from emmettbutler November 20, 2026 16:34

@datadog-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

The bridge replacement violates the existing CODEOWNERS file freeze, causing the freeze workflow to reject the PR. A separate prerequisite PR must lift the freeze before this change can pass.

Open Bits AI session

🤖 Bits Code Review · Commit 8c6734f

Comment thread ddtrace/internal/codeowners.py Resolved

@emmettbutler emmettbutler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Nov 20, 2026
Removed frozen entry for codeowners

Requirement for: #21725


Co-authored-by: brett.langdon <brett.langdon@datadoghq.com>

@datadog-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The PR replaces the vendored CODEOWNERS implementation with a bridge to _ddtrace_internal.codeowners and pins ddtrace-internal to 0.3.0 across runtime, lint, and requirements files. It adds a bridge identity check and an upgrade note for private mirrors. The earlier freeze blocker is resolved: neither the current base nor head freezes codeowners.py. No reportable findings remain; runtime behavior was not exercised.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 8a30f08

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit b9d1844 into main Nov 23, 2026
909 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the gnufede/bridge branch November 23, 2026 09:37
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Nov 23, 2026
## Description

The freeze check enforced the `frozen-paths.txt` manifest at both the PR base and the merge result, so a PR could not lift its own freeze: unfreezing required one PR that removed the entry while leaving the file untouched, and a second, later PR with the authorized change (e.g. replacing the file with a bridge to the extracted package — #21979 then #21725). That gap left the path unprotected on main between the two merges, risking drift or lost work.

An entry removed from the merge-result manifest now unfreezes its path in the same PR: the manifest removal and the change it authorizes (bridge code) can land together. What stays enforced:

- Base rules still use the target base, so branches predating a freeze are checked too.
- Base rules still block updating an entry's hash in the same PR — only removing the entry unfreezes.
- Merge rules still validate every freeze on the merge result, including newly added ones.
- Manifest edits remain gated by the CODEOWNERS entry on `/frozen-paths.txt` (@DataDog/apm-core-python), which is the human authorization for a same-PR unfreeze.

Unfrozen paths are reported as `::notice::` annotations for an audit trail of what a PR unfreezes.

## Testing

- Ran the exact workflow shell (extracted from `freeze-check.yml`) against synthetic base/merge git states — 12 scenarios, all passing:
  - change file + remove entry (bridge) → pass with notice
  - change file + keep entry (old hash) → fail
  - change file + update hash in same PR → fail (hash update must not lift a freeze)
  - remove entry, file unchanged → pass with notice
  - delete frozen file + remove entry → pass with notice
  - new freeze with correct/wrong hash → pass/fail
  - base predating a freeze → merge rules still enforced
  - remove manifest entirely → pass
  - unfreeze one path while changing another still-frozen path → fail
- `scripts/lint checks` — all passing.
- Runtime tests/benchmarks unnecessary: CI metadata only.

## Risks

The freeze check no longer structurally prevents a PR author from removing an entry and changing the file in the same PR. Authorization relies on the required CODEOWNERS review of `/frozen-paths.txt` from @DataDog/apm-core-python (branch protection) — same trust model as manifest edits in general.

## Additional Notes

No release note: CI metadata only, no customer-visible behavior (`changelog/no-changelog`).


Co-authored-by: federico.mon <federico.mon@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants