Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ddtrace/testing/internal/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ def serialize_test_run(test_run: TestRun) -> Event:


def serialize_suite(suite: TestSuite) -> Event:
# The plugin sets a module's path when it discovers the module; a module built without one still serializes.
module_path = getattr(suite.module, "module_path", None)
module_path_tag = {"test.module_path": module_path} if module_path is not None else {}
content = {
"service": suite.service,
"resource": suite.name,
Expand All @@ -625,6 +628,8 @@ def serialize_suite(suite: TestSuite) -> Event:
"duration": suite.duration_ns,
"meta": {
"span.kind": "test",
"test.module": suite.module.name,
**module_path_tag,
"test.suite": suite.name,
"test.status": suite.get_status().value,
"type": "test_suite_end",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
CI Visibility: Fixes test suite events from the ``pytest`` plugin missing the ``test.module`` and
``test.module_path`` tags, which kept Datadog from recording test suite durations per module.
3 changes: 3 additions & 0 deletions tests/testing/internal/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ def create_mock_test_suite(self) -> TestSuite:
suite.name = "TestSuite"
suite.session.item_id = 666
suite.module.item_id = 777
suite.module.module_path = "/path/to/test_module"
suite.item_id = 888
suite.tags = {"suite.custom": "suite_value"}
suite.metrics = {"suite.metric": 100}
Expand All @@ -932,6 +933,8 @@ def test_serialize_suite(self) -> None:
# Check metadata
meta = event["content"]["meta"]
assert meta["span.kind"] == "test"
assert meta["test.module"] == "test_module"
assert meta["test.module_path"] == "/path/to/test_module"
assert meta["test.suite"] == "TestSuite"
assert meta["test.status"] == "pass"
assert meta["type"] == "test_suite_end"
Expand Down
Loading