Repository navigation
fix(ci_visibility): add test.module to pytest test suite events - #21477
tonyredondo wants to merge 1 commit into
Conversation
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.
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 0f1eb84 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
More details
Suite events receive the module identity needed for duration lookup, while modules without a path still serialize safely.
🤖 Bits Code Review · Commit 0f1eb84
BenchmarksBenchmark execution time: 2026-11-03 15:30:04 Comparing candidate commit 0f1eb84 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 388 metrics, 9 unstable metrics.
|
Description
Test suite events (
test_suite_end) from thepytestplugin carrytest_module_id, but not thetest.moduleandtest.module_pathtags that test and module events set.serialize_suitenow addstest.modulefrom the suite's module, andtest.module_pathwhen 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_durationsreturned 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.test_utils.py, overwrote each other.Testing
test_serialize_suitenow checks both tags. Without the change, it fails withKeyError: 'test.module'.tests/testing/internal/test_writer.pypasses, and so dotest_test_data.pyand the plugin tests that look at suite events (333 tests in all).tests/testing/suite, run with the CI command, has 5 failures intest_pytest_bdd.py, whichmainhas 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_pathtag 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.