Skip to content

fix(ci_visibility): add ITR correlation ID#19141

Open
gnufede wants to merge 8 commits into
mainfrom
gnufede/SDTEST-3902
Open

fix(ci_visibility): add ITR correlation ID#19141
gnufede wants to merge 8 commits into
mainfrom
gnufede/SDTEST-3902

Conversation

@gnufede

@gnufede gnufede commented Jul 17, 2026

Copy link
Copy Markdown
Member

Description

Adds the ITR correlation ID to the content.itr_correlation_id field for ddtrace.testing citestcycle test/suite events when ITR is enabled and the skippable endpoint returns a correlation ID.

The correlation ID was already parsed from the skippable response and emitted in citestcycle metadata. This change also propagates it onto serialized event content, matching other tracers’ behavior where all test/suite events in an ITR-enabled session carry the session-wide correlation ID.

Testing

  • Added serializer coverage for:
    • test events with content.itr_correlation_id
    • suite events with content.itr_correlation_id
    • events without a session correlation ID omitting the field

Risks

Low. The field is only added when a correlation ID was returned by the ITR skippable endpoint. Existing metadata emission is preserved.

Additional Notes

Aligned with JavaScript and Java tracer behavior.

@gnufede gnufede added the CI App label Jul 17, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

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

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codeowners resolved as

releasenotes/notes/ci-visibility-itr-correlation-id-13e6e7d8deaf7b99.yaml  @DataDog/apm-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 17, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

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

Show existing cycles (showing 5 of 45 shortest)
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.botocore -> ddtrace.internal.datastreams
ddtrace.internal.core -> ddtrace._trace.span -> ddtrace.internal.core
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.google_cloud_pubsub -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.kafka -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.aiokafka -> ddtrace.internal.datastreams

To see all cycles, download the cycles-base.json and cycles-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/cycles.py compare cycles-base.json cycles-pr.json

@gnufede

gnufede commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bad4f0d908

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

skipping_enabled=self.settings.skipping_enabled,
skipping_level=self.itr_skipping_level,
)
self.session.itr_correlation_id = self.itr_correlation_id

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the existing ITR payload metadata

When the skippable endpoint returns a correlation ID, this now stores it only on TestSession for event serialization, but the previous writer.add_metadata("test"/"test_suite_end", {"itr_correlation_id": ...}) call was removed. That means citestcycle payloads no longer include the existing metadata["test"] or metadata["test_suite_end"] correlation ID, which is a backward-compatibility regression for any backend path still reading the payload metadata while this change adds the new content.itr_correlation_id field. Re-add the metadata emission in addition to this session propagation.

Useful? React with 👍 / 👎.

@gnufede
gnufede marked this pull request as ready for review July 17, 2026 15:18
@gnufede
gnufede requested review from a team as code owners July 17, 2026 15:18
@gnufede

gnufede commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

E2E Test Results ✅

Tested on the flask playground (12,381 tests, 554 suites) against mockdog with the itr-flask-suite-skips scenario, using both ITR skipping modes.

TEST-level mode (default)

Event type With itr_correlation_id Without
Test events 3165 / 3165 0
Suite events 0 69

SUITE-level mode (_DD_CIVISIBILITY_ITR_SUITE_MODE=true)

Event type With itr_correlation_id Without
Test events 0 3161
Suite events 69 / 69 0

itr_correlation_id = "mockdog-correlation-id" (the value returned by the skippable endpoint) is present on every event at the active skipping level, and absent from the other level. The level-gating works exactly as the spec requires.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bad4f0d908

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"test_module_id": test_run.module.item_id,
"test_suite_id": test_run.suite.item_id,
}
if test_run.session.itr_correlation_id and test_run.session.itr_skipping_level == ITRSkippingLevel.TEST:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the ID on suite-mode test skips

When suite-skipping is active and a skippable file contains the datadog_itr_unskippable marker, _pytest_ignore_collect_impl falls back to normal collection, and _handle_itr still skips the other tests because their suite is in skippable_items. Those skipped records are serialized as test events while session.itr_skipping_level is SUITE, so this condition drops content.itr_correlation_id from the events that need it for skip details; include it for test events that are marked skipped by ITR, or avoid gating purely on the session level.

Useful? React with 👍 / 👎.

@brettlangdon brettlangdon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release note probably could be shortened, but overall pretty good

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

The PR correctly adds ITR correlation ID to test/suite event content with proper conditional logic. The correlation ID is only added when present AND the skipping level matches the event type (TEST for test events, SUITE for suite events). All edge cases are covered by comprehensive tests: missing correlation IDs are omitted, correlation IDs at non-matching skipping levels are omitted, and other event fields are preserved. The refactoring inlines a helper function while maintaining identical behavior.

Was this helpful? React 👍 or 👎

📊 Validated against 9 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit bad4f0d · What is Autotest? · Any feedback? Reach out in #autotest

Comment thread releasenotes/notes/ci-visibility-itr-correlation-id-13e6e7d8deaf7b99.yaml Outdated
@gnufede gnufede changed the title fix(testing): add ITR correlation ID fix(ci_visibility): add ITR correlation ID Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants