feat(ci_visibility): support DD_TEST_OPTIMIZATION_RUNTIME_TAGS #22090
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/ci_visibility/recorder.py @DataDog/ci-app-libraries
ddtrace/internal/settings/_supported_configurations.py @DataDog/apm-python
ddtrace/testing/internal/constants.py @DataDog/ci-app-libraries
ddtrace/testing/internal/platform.py @DataDog/ci-app-libraries
ddtrace/testing/internal/pytest/plugin.py @DataDog/ci-app-libraries
ddtrace/testing/internal/session_manager.py @DataDog/ci-app-libraries
docs/configuration.rst @DataDog/apm-python-guild
releasenotes/notes/ci-visibility-runtime-tags-override-3d1454313c5936bf.yaml @DataDog/apm-python
supported-configurations.json @DataDog/apm-python
tests/ci_visibility/test_ci_visibility.py @DataDog/ci-app-libraries
tests/testing/internal/pytest/test_pytest_ddtrace_tags.py @DataDog/ci-app-libraries
tests/testing/internal/test_platform.py @DataDog/ci-app-libraries
tests/testing/mocks.py @DataDog/ci-app-libraries
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 >
<a target='_blank' href='https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest+%40git.commit.sha%3A71003442b270ac450e1c35a9a105f741867d345a&referrer=pr-comment&start=1796036992000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-warning.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-warning-light.svg" alt="Tests" align="center" /></picture></a> <a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40git.commit.sha%3Ac820a586adc5b0630786ee46702cd144b7a11889&referrer=pr-comment&start=1796036992000'><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>
⚠️ Warnings
Your PR has warnings. Please review the issues below.
❄️ 8 New flaky tests detected
<blockquote>
<div>
<details>
<summary><code>TestRuntimeTagsOverrides::test_invalid_value_logs_warning_and_keeps_detected_tags["6.12.0"][py3.10]</code> from <code>test_platform.py</code></summary>
assert 'DD_TEST_OPTIMIZATION_RUNTIME_TAGS' in ''
+ where '' = <_pytest.logging.LogCaptureFixture object at 0x7c69083adf00>.text
</details>
<details>
<summary><code>TestRuntimeTagsOverrides::test_invalid_value_logs_warning_and_keeps_detected_tags["6.12.0"][py3.9]</code> from <code>test_platform.py</code></summary>
assert 'DD_TEST_OPTIMIZATION_RUNTIME_TAGS' in ''
+ where '' = <_pytest.logging.LogCaptureFixture object at 0x73a917e35ee0>.text
</details>
</div>
ℹ️ Info
<details><summary>No other issues found (see more)</summary>
🧪 All tests passed
</details>
Useful? React with 👍 / 👎
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: c820a58 | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RkLXRyYWNlLXB5LzIyMDkw?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":"c820a586adc5b0630786ee46702cd144b7a11889","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":"c820a586adc5b0630786ee46702cd144b7a11889","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} -->
<!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"c820a586adc5b0630786ee46702cd144b7a11889","mergeGateEnabled":false,"pullRequestNumber":22090,"repository":"DataDog/dd-trace-py","status":"completed"} -->
<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-11-30T11:44:27.161101Z">2026-11-30T11:44:27.161101Z</relative-time> | c820a58 | New commits |
| 🔒 Security Review | ✅ Completed <relative-time datetime="2026-11-30T11:46:20.613943Z">2026-11-30T11:46:20.613943Z</relative-time> | c820a58 | 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>
Approved these changes.
<details>
<summary>More details</summary>
Override parsing preserves detected values for unsupported or unusable inputs, and propagation remains confined to Test Optimization metadata. The completed static review identified no reportable defect.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 46eceff</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=ed609da4-565d-4934-920b-b38175aac6d8 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:72a206c3e978b92e0fd512eb3f1e90d2078abe7191d22ef4b1ec4cd9e078d6bd:bundle -->
Benchmarks
Benchmark execution time: 2026-11-30 12:10:25
Comparing candidate commit c820a586adc5b0630786ee46702cd144b7a11889 in PR branch daniel.mohedano/runtime-tags-override with baseline commit 21b6f4c80ca9f19f63149ce218575f7c8b243315 in branch main.
Found 0 performance improvements and 0 performance regressions! Performance is the same for 605 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>
<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 [-707.814ns; +775.068ns] or [-6.655%; +7.287%]scenario:coreapiscenario-core_dispatch_1_listener
execution_time [-38.966ns; +39.840ns] or [-6.105%; +6.242%]scenario:coreapiscenario-core_dispatch_50_listeners
execution_time [-1910.311ns; +1912.318ns] or [-9.566%; +9.576%]scenario:coreapiscenario-core_dispatch_exception_listeners
execution_time [-1954.633ns; +1727.830ns] or [-10.051%; +8.885%]scenario:coreapiscenario-core_dispatch_listeners
execution_time [-373.367ns; +386.788ns] or [-8.798%; +9.114%]scenario:coreapiscenario-core_dispatch_no_args_listeners
execution_time [-232.855ns; +224.186ns] or [-8.751%; +8.426%]scenario:coreapiscenario-core_dispatch_with_results_1_listener
execution_time [-95.319ns; +85.909ns] or [-6.925%; +6.242%]scenario:coreapiscenario-core_dispatch_with_results_50_listeners
execution_time [-4567.776ns; +4751.545ns] or [-9.396%; +9.774%]scenario:coreapiscenario-core_dispatch_with_results_listeners
execution_time [-981.123ns; +886.289ns] or [-9.586%; +8.659%]scenario:packagesupdateimporteddependencies-import_many_stdlib_cached
execution_time [-54.131µs; +59.163µs] or [-9.246%; +10.105%]</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>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:2d1603d601bff99581f636328281e252b77393cb16fe491d14f09ee586bffff0:inline-0 -->
<sub><sub>!P1</sub></sub> Initialize runtime overrides in the session-manager mock
<!-- autotest-finding-meta prod_data_type=none finding_id=baba76b9-b01c-459d-9ad7-bb00a8266b52 prod_effect=static -->
SessionManagerMockBuilder.build_mock() creates Mock(spec=SessionManager) without initializing runtime_tags_overrides, which exists only on initialized instances. Both existing final-status tests call this new access through _do_test_runs(), so they now raise AttributeError even when the environment variable is unset. Initialize runtime_tags_overrides to {} in tests/testing/mocks.py so those tests can complete.
<!-- 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/ed609da4-565d-4934-920b-b38175aac6d8?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
DD_TEST_OPTIMIZATION_RUNTIME_TAGS pins OS/runtime metadata across Test Optimization events and configurations; the latest commit snapshots overrides and fixes precedence over span tags. One issue remains: existing plugin tests raise AttributeError because their session-manager mock lacks runtime_tags_overrides; no earlier findings were open.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit c87ed46</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=ed609da4-565d-4934-920b-b38175aac6d8 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:2d1603d601bff99581f636328281e252b77393cb16fe491d14f09ee586bffff0:bundle -->
Fixed in 0c475c2bd6: the mock now sets runtime_tags_overrides = {}.
<details>
<summary>More details</summary>
The PR adds validated OS/runtime overrides for Test Optimization events and request configurations, with explicit overrides taking precedence over span tags. The latest commit fixes the session-manager mock initialization failure; no findings remain open, and validation is limited to static review.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 0c475c2</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=ed609da4-565d-4934-920b-b38175aac6d8 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:134e91a0356d2d0b48ee4e963f703812471ce982949c6500890c6f7853923b8f:bundle -->
<details>
<summary>More details</summary>
The completed static review found no actionable defect in override validation or propagation through pytest, legacy CIVisibility, and request configurations. Human PR discussion did not change that conclusion.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit c820a58</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=ecfd34ed-65b9-41db-8683-fac81bceb680 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:f10bf26eae68787341711080ba1288105dac7679f6e43a03f2e4e497a895d391:bundle -->
/merge
<!-- "FeedbackWorkflowId":"69a7a8c2-425d-43bd-a676-da7f2c6690d6_39" -->
View all feedbacks in Devflow UI.
2026-12-01 14:53:22 UTC :information_source: Start processing command /merge
---2026-12-01 14:53:27 UTC :information_source: MergeQueue: pull request added to the queue
The expected merge time in main is approximately 1h (p90).
---2026-12-01 15:30:20 UTC :x: MergeQueue: The build pipeline failed for this merge request
Build pipeline has failing jobs for 894efb9:
...
What to do next?
This build will be kept for 3h more. During that period, you can retry the pipeline or the failing jobs and then re-run the same command!
If you want to reset everything, you can cancel your previous command by rerunning it with the -c flag.
/merge
<!-- "FeedbackWorkflowId":"2dce6bc8-7ccf-42aa-aa1e-36ecd91c1aa6_39" -->
View all feedbacks in Devflow UI.
2026-12-02 10:22:39 UTC :information_source: Start processing command /merge
---2026-12-02 10:22:44 UTC :information_source: MergeQueue: pull request added to the queue
The expected merge time in main is approximately 1h (p90).
---2026-12-02 11:04:53 UTC :x: MergeQueue: The build pipeline failed for this merge request
Build pipeline has failing jobs for da37abb:
What to do next?
This build will be kept for 3h more. During that period, you can retry the pipeline or the failing jobs and then re-run the same command!
If you want to reset everything, you can cancel your previous command by rerunning it with the -c flag.
gnufede
daniel-mohedano
Description
Adds the
DD_TEST_OPTIMIZATION_RUNTIME_TAGSenvironment variable. It takes a JSON object, such as{"os.version": "6.12.0"}, that replaces the detected OS and runtime tags reported to Test Optimization.os.platform,os.architecture,os.version,runtime.nameandruntime.version. Other keys, non-string values and blank values are ignored.configurations. This covers the pytest plugin (ddtrace.testing) and the legacyCIVisibilityservice used by unittest.ddtrace.ext.cihelpers keep returning the detected values.test.framework_versionfor unittest stays the real Python version.Motivation: TIA only reuses coverage recorded with exactly the same OS and runtime tags. When a runner's kernel or Python patch version changes, the next runs skip nothing until the default branch runs again on the new value. Pinning the value keeps skipping working across those updates.
datadog-ci-rbandddtestalready read this variable, and this PR is part of adding it to every Test Optimization library.Testing
tests/testing/internal/test_platform.py, including invalid and deeply nested input.CIVisibilitytest that checks the legacy recorder applies the override to_configurationsand_tags. It fails without the recorder change.main.Risks
None when the variable is unset. The parser runs once per session.
Additional Notes
supported-configurations.jsonuses implementationA. The key still needs to be registered in the Feature Parity registry.