Skip to content

fix(ci_visibility): add test.module to pytest test suite events - #21477

Open
tonyredondo wants to merge 1 commit into
mainfrom
tony.redondo/suite-events-test-module
Open

tonyredondo wants to merge 1 commit into
mainfrom
tony.redondo/suite-events-test-module

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

Description

Test suite events (test_suite_end) from the pytest plugin carry test_module_id, but not the test.module and test.module_path tags that test and module events set. serialize_suite now adds test.module from the suite's module, and test.module_path when the module has a path, which the plugin sets whenever it discovers a module.

This matters for suite durations. Datadog's durations writer keys each suite's duration by the suite event's own test.module, so every Python suite is stored under an empty module name. With networkx on ddtrace 4.16.1:

  • POST /api/v2/ci/ddtest/test_suite_durations returned 248 suites, all under the module "". ddtest looks durations up by module and suite name, so it matched none and split the tests by test count.
  • networkx reported 264 suites. Suites with the same file name in different directories, such as its several test_utils.py, overwrote each other.

Testing

  • test_serialize_suite now checks both tags. Without the change, it fails with KeyError: 'test.module'.
  • Locally, on a source build with Python 3.12 and pytest 8.4, tests/testing/internal/test_writer.py passes, and so do test_test_data.py and the plugin tests that look at suite events (333 tests in all).
  • The whole tests/testing/ suite, run with the CI command, has 5 failures in test_pytest_bdd.py, which main has too in that environment (pytest-bdd 9.0.1).

Risks

Suite events gain two tags that test and module events already have. A module without a path, as some unit tests build, gets no test.module_path tag instead of failing to serialize.

Additional Notes

The same problem exists in the 4.16 and 4.17 release lines, if you'd like to backport the fix.

Test suite events from the pytest plugin carry test_module_id but not the
test.module and test.module_path tags that test and module events have.
Datadog keys suite durations by the suite event's test.module, so every
Python suite was stored under an empty module: ddtest, which looks
durations up by module and suite, matched none, and suites with the same
file name in different directories overwrote each other.

serialize_suite now sets both tags from the suite's module, as
serialize_test_run does.
@cit-pr-commenter-54b7da

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/testing/internal/writer.py                                      @DataDog/ci-app-libraries
releasenotes/notes/ci-visibility-suite-test-module-14f316ae5b509668.yaml  @DataDog/apm-python
tests/testing/internal/test_writer.py                                   @DataDog/ci-app-libraries

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 102 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=122)
ddtrace.llmobs._integrations.vertexai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=120)
ddtrace.llmobs._integrations.google_adk -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=120)
ddtrace.llmobs._integrations.openai_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=120)
ddtrace.llmobs._integrations.claude_agent_sdk -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=120)

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

@tonyredondo
tonyredondo marked this pull request as ready for review November 3, 2026 15:21
@tonyredondo
tonyredondo requested review from a team as code owners November 3, 2026 15:21
@tonyredondo
tonyredondo requested review from ncybul and removed request for a team November 3, 2026 15:21
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T15:23:29.755769Z 0f1eb84 Draft marked ready
🔒 Security Review ✅ Completed 2026-11-03T15:24:59.832083Z 0f1eb84 Draft marked ready
ℹ️ 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.

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

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

Copy link
Copy Markdown

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

Suite events receive the module identity needed for duration lookup, while modules without a path still serialize safely.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 0f1eb84

@pr-commenter

pr-commenter Bot commented Nov 3, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-03 15:30:04

Comparing candidate commit 0f1eb84 in PR branch tony.redondo/suite-events-test-module with baseline commit e8ee71b in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 388 metrics, 9 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 ----------------------------------'

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 [-747.553ns; +701.294ns] or [-6.959%; +6.528%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-35.445ns; +36.047ns] or [-5.146%; +5.233%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1908.133ns; +1886.776ns] or [-9.569%; +9.462%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-2007.458ns; +1648.454ns] or [-10.395%; +8.536%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-368.644ns; +387.956ns] or [-8.458%; +8.901%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-221.862ns; +227.806ns] or [-8.215%; +8.435%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-77.677ns; +99.714ns] or [-5.498%; +7.058%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-4543.578ns; +5008.534ns] or [-9.088%; +10.018%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-1045.503ns; +912.101ns] or [-9.752%; +8.508%]

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.

2 participants