Skip to content

ci: run test environments with uv - #19713

Draft
mabdinur wants to merge 35 commits into
mainfrom
codex/migrate-tracer-hatch
Draft

ci: run test environments with uv#19713
mabdinur wants to merge 35 commits into
mainfrom
codex/migrate-tracer-hatch

Conversation

@mabdinur

@mabdinur mabdinur commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

Replaces Riot and the temporary Hatch canary with direct uv test environments while preserving the useful build-once design.

  • Deletes riotfile.py, .riot, Riot/Hatch runtime dependencies, and the transition contract.
  • Preserves 1,936 ordered environment instances, 1,886 stable IDs, and all 193 named selectors used by local development and CI.
  • Stores shared dependencies and variables in tests/environments/core.json, reusable profiles in definitions/, and resolved instances in Windows-safe named-node shards.
  • Builds ddtrace once per Python version, installs each checked-in lock into a reusable uv dependency prefix, and launches every resolved command in a fresh subprocess.
  • Routes local tests, generated GitLab jobs, docs, lock maintenance, dependency checks, and integration-registry tooling through uv.
  • Removes the nested extension-cache venv and runs that tool as a uv script with declared build dependencies.
  • Keeps tracer and tracer-uwsgi selectors exclusive, removing five duplicate jobs (about 16.2 runner-minutes in the measured pipeline).

Riot reused editable base environments; it did not build or reuse dev wheels. The uv runner retains that reuse without a second environment manager.

Testing

Local validation on the final migration commit:

  • scripts/test_environments.py check: 1,936 instances, 193 named nodes, 1,886 unique environments.
  • scripts/compile-test-environment-locks: validated 1,886 locks; compiled 0; removed 0.
  • Lock comparison: 1,885 moved lock bodies are unchanged. The integration-registry lock intentionally drops Riot and its transitive dependencies.
  • uv tooling and generator tests: 30 passed on Python 3.12.
  • Integration-registry tests: 4 passed on Python 3.13.
  • Exact CI extension-cache restore command: passed after adding the conditional patchelf build dependency.
  • Test-environment, suitespec, CI dependency, installability, and dependency-coverage checks: passed. Existing latest-range warnings remain.
  • Full scripts/lint checks: passed after the final Windows portability correction.

Performance evidence:

Experiment Result
First Hatch canary, independent build Failed after roughly 4, 20, and 14 minutes across attempts
Hatch reusing the Python 3.12 base 555 s
Equivalent Riot shard in the same pipeline 565 s
Local full config generation before in-process IDs 24.6 s
Local full config generation after 0.69 s
First local uv Python 3.12 editable build 46.65 s build + 0.16 s install
Warm base fingerprint check, including container startup 1.97 s

The 10-second Hatch difference is 1.8% and within single-run noise. Hatch added environment ownership and bootstrap failure modes without a measured runtime win, so direct uv is the simpler path.

Real CI checkpoint 0d13ea1a36 routed all generated tests through uv. Its configuration job passed; the monolithic JSON inventory hit the 100 KB file gate, and all six base jobs failed before consumers ran. This commit fixes the size gate by sharding around preserved names, resolves exact preinstalled interpreters, removes the nested extension-cache environment, and locally reproduces the replacement command. The next real run must validate the base-build correction and provide clean end-to-end timings.

Risks

  • This is a large mechanical configuration migration. Stable names, IDs, order, commands, dependency order, and variables are validated, but broad platform and service coverage still depends on the fresh CI run.
  • Existing pytest/xdist sessions can run multiple tests in one interpreter. This PR starts one process per environment command; it does not falsely claim one clean process per span-producing test.
  • Snapshot tests still require both a fresh Python process and isolated test-agent session. The enforcement migration is ranked as the top correctness item in the CI bottleneck document.

Additional Notes

docs/contributing-ci-performance.rst is the living, ranked register for isolation, duration-blind ordering, snapshot-agent cost, cache duplication, retries, subprocess paths, measurements, and next experiments.

This is internal test infrastructure with no customer-facing behavior change. The PR has the changelog/no-changelog label.

@mabdinur mabdinur added changelog/no-changelog A changelog entry is not required for this PR. AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos labels Aug 14, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 4 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | core/internal 1/6   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | core/internal 3/6   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | core/internal 5/6   View in Datadog   GitLab

View all 4 failed jobs.

🧪 50 Tests failed in 7 jobs

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 12/14

    PytestSnapshotTestCase::test_pytest_will_include_lines_pct[py3.11] from test_pytest_snapshot_v2.py   View in Datadog

    PytestSnapshotTestCase::test_pytest_with_ddtrace_patch_all[py3.11] from test_pytest_snapshot_v2.py   View in Datadog

View all failed tests

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 2/14

    PytestSnapshotTestCase::test_pytest_will_include_lines_pct[py3.9] from test_pytest_snapshot.py   View in Datadog

    PytestSnapshotTestCase::test_pytest_with_ddtrace_patch_all[py3.9] from test_pytest_snapshot.py   View in Datadog

View all failed tests

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 4/14

    PytestSnapshotTestCase::test_pytest_will_include_lines_pct[py3.13] from test_pytest_snapshot.py   View in Datadog

    PytestSnapshotTestCase::test_pytest_with_ddtrace_patch_all[py3.13] from test_pytest_snapshot.py   View in Datadog

View all failed tests

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 5/14

    PytestSnapshotTestCase::test_pytest_will_include_lines_pct[py3.10] from test_pytest_snapshot.py   View in Datadog

    PytestSnapshotTestCase::test_pytest_with_ddtrace_patch_all[py3.10] from test_pytest_snapshot.py   View in Datadog

View all failed tests

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 6/14

    PytestSnapshotTestCase::test_pytest_will_include_lines_pct[py3.12] from test_pytest_snapshot.py   View in Datadog

    PytestSnapshotTestCase::test_pytest_with_ddtrace_patch_all[py3.12] from test_pytest_snapshot.py   View in Datadog

View all failed tests

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 8/14

    PytestSnapshotTestCase::test_pytest_will_include_lines_pct[py3.11] from test_pytest_snapshot.py   View in Datadog

    PytestSnapshotTestCase::test_pytest_with_ddtrace_patch_all[py3.11] from test_pytest_snapshot.py   View in Datadog

View all failed tests

DataDog/apm-reliability/dd-trace-py | ci_visibility/pytest:snapshot 9/14

    PytestXdistSnapshotTestCase::test_pytest_xdist_n2_wont_include_lines_pct_if_report_empty[py3.12] from test_pytest_xdist_snapshot.py   View in Datadog

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c502604 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter

pr-commenter Bot commented Aug 15, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-15 01:05:27

Comparing candidate commit d27d003 in PR branch codex/migrate-tracer-hatch with baseline commit e5c63be in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 8 performance regressions! Performance is the same for 613 metrics, 10 unstable metrics.

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

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.532µs; +2.699µs] or [+11.690%; +12.458%]

scenario:iastaspects-lstrip_aspect

  • 🟥 execution_time [+70.676µs; +77.535µs] or [+24.634%; +27.024%]

scenario:iastaspects-translate_aspect

  • 🟥 execution_time [+61.566µs; +68.173µs] or [+14.695%; +16.272%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+134.427µs; +141.640µs] or [+33.278%; +35.064%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+13.843µs; +18.774µs] or [+9.736%; +13.204%]

scenario:span-start

  • 🟥 execution_time [+1.252ms; +1.409ms] or [+8.273%; +9.308%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+428.808ns; +473.323ns] or [+16.194%; +17.875%]

scenario:tracer-small

  • 🟥 execution_time [+28.758µs; +31.395µs] or [+8.482%; +9.260%]

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 [-912.651ns; +574.816ns] or [-8.226%; +5.181%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-39.321ns; +27.094ns] or [-6.406%; +4.414%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1757.574ns; +1533.829ns] or [-10.292%; +8.982%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1205.853ns; +1255.626ns] or [-9.335%; +9.720%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-335.322ns; +315.679ns] or [-9.120%; +8.586%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-261.441ns; +250.321ns] or [-8.928%; +8.548%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-127.779ns; +22.823ns] or [-10.623%; +1.897%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3487.244ns; +4527.346ns] or [-8.607%; +11.174%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-763.948ns; +769.021ns] or [-9.399%; +9.462%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-61.914µs; +59.254µs] or [-9.685%; +9.269%]

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 15, 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.

.claude/skills/run-tests/SKILL.md                                       @DataDog/python-guild
.gitignore                                                              @DataDog/apm-core-python
.gitlab-ci.yml                                                          @DataDog/python-guild @DataDog/apm-core-python
.gitlab/templates/build-base-venvs.yml                                  @DataDog/python-guild @DataDog/apm-core-python
.gitlab/tests.yml                                                       @DataDog/python-guild @DataDog/apm-core-python
docs/contributing-ci-performance.rst                                    @DataDog/python-guild
docs/contributing-testing.rst                                           @DataDog/python-guild
docs/contributing.rst                                                   @DataDog/python-guild
pyproject.toml                                                          @DataDog/python-guild
riotfile.py                                                             @DataDog/apm-python
scripts/build-uv-base                                                   @DataDog/python-guild
scripts/gen_gitlab_config.py                                            @DataDog/python-guild
scripts/run-tests                                                       @DataDog/python-guild
scripts/run-uv-test-env                                                 @DataDog/python-guild
scripts/test_env_contract.py                                            @DataDog/python-guild
scripts/test_environments.py                                            @DataDog/python-guild
scripts/uv_compat/sitecustomize.py                                      @DataDog/python-guild
scripts/uv_test_env.py                                                  @DataDog/python-guild
tests/environments/core.json                                            @DataDog/apm-core-python
tests/environments/inventory.json                                       @DataDog/apm-core-python
tests/environments/riot-contract.json                                   @DataDog/apm-core-python
tests/internal/test_build_uv_base.py                                    @DataDog/apm-core-python
tests/internal/test_gen_gitlab_config.py                                @DataDog/apm-core-python
tests/internal/test_test_env_contract.py                                @DataDog/apm-core-python
tests/internal/test_test_environments.py                                @DataDog/apm-core-python
tests/internal/test_uv_test_env.py                                      @DataDog/apm-core-python
tests/suitespec.yml                                                     @DataDog/python-guild

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 15, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 5 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.contrib.internal.django.patch -> ddtrace.contrib.internal.django.response -> ddtrace.contrib.internal.django.patch
ddtrace.contrib.internal.pytorch._distributed -> ddtrace.contrib.internal.pytorch._rank_root -> ddtrace.contrib.internal.pytorch._distributed
ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 15, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 254 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 254 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._utils -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.internal.ci_visibility.git_client -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=132)
ddtrace.appsec._listeners -×-> ddtrace.trace  (product:appsec -> product:tracing, score=132)
ddtrace.aiguard._api_client -×-> ddtrace.trace  (product:aiguard -> product:tracing, score=132)

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

@mabdinur mabdinur changed the title ci: migrate tracer tests to Hatch and uv ci: run tests with Hatch and uv Aug 15, 2026
@mabdinur mabdinur changed the title ci: run tests with Hatch and uv ci: run test environments with uv Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant