Skip to content

feat(test-optimization): create final_status tag on test event for jest#7356

Merged
calvinbayer merged 7 commits intomasterfrom
calvin.bayer/feat/SDTEST-2980/create-final-status-tag-for-jest
Feb 2, 2026
Merged

feat(test-optimization): create final_status tag on test event for jest#7356
calvinbayer merged 7 commits intomasterfrom
calvin.bayer/feat/SDTEST-2980/create-final-status-tag-for-jest

Conversation

@calvinbayer
Copy link
Copy Markdown
Contributor

@calvinbayer calvinbayer commented Jan 27, 2026

What does this PR do?

Create a @test.final_status tag that is added to every test event that represents the final execution of that test (there can be multiple executions of a single test due to retry mechanisms being active)

Motivation

Tracers send each test execution as a span to the backend. When retry mechanisms are enabled a single test can run several times with different outcomes. These mechanisms differ in behavior. Some stop once the test reaches the desired state such as ATR ending when a test passes. Others always run a fixed number of attempts such as EFD or Attempt to fix.

To ensure the correct final result for the customer some intermediate outcomes are suppressed and the testing framework receives an adjusted final status. For example if an early EFD attempt passes but later attempts fail the test is still reported as passed and the failing attempts are hidden to avoid failing CI pipelines.

Both external and internal users have requested a way to query tests in Datadog by this final status. Their main goal is to build monitors and alerts for hard failures on default branches.

To support this a new tag will be added to the last retry of a test named: @test.final_status:pass|fail|skip

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Jan 27, 2026

Benchmarks

Benchmark execution time: 2026-02-02 12:16:01

Comparing candidate commit 980e0d5 in PR branch calvin.bayer/feat/SDTEST-2980/create-final-status-tag-for-jest with baseline commit c80bbc2 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 229 metrics, 31 unstable metrics.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.56%. Comparing base (c80bbc2) to head (980e0d5).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
packages/datadog-plugin-jest/src/index.js 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7356      +/-   ##
==========================================
- Coverage   80.56%   80.56%   -0.01%     
==========================================
  Files         731      731              
  Lines       31236    31240       +4     
==========================================
+ Hits        25166    25167       +1     
- Misses       6070     6073       +3     
Flag Coverage Δ
aiguard-macos 39.11% <ø> (-0.11%) ⬇️
aiguard-ubuntu 39.15% <ø> (-0.11%) ⬇️
aiguard-windows 39.00% <ø> (-0.11%) ⬇️
apm-capabilities-tracing-macos 48.91% <25.00%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu 48.91% <25.00%> (-0.01%) ⬇️
apm-capabilities-tracing-windows 48.64% <25.00%> (-0.01%) ⬇️
apm-integrations-child-process 38.61% <ø> (-0.11%) ⬇️
apm-integrations-couchbase-18 37.33% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-eol 37.81% <ø> (-0.11%) ⬇️
apm-integrations-oracledb 38.01% <ø> (-0.10%) ⬇️
appsec-express 55.46% <ø> (-0.08%) ⬇️
appsec-fastify 52.06% <ø> (-0.08%) ⬇️
appsec-graphql 52.39% <ø> (-0.07%) ⬇️
appsec-kafka 44.68% <ø> (-0.09%) ⬇️
appsec-ldapjs 44.35% <ø> (-0.09%) ⬇️
appsec-lodash 44.03% <ø> (-0.09%) ⬇️
appsec-macos 58.53% <100.00%> (-0.06%) ⬇️
appsec-mongodb-core 49.27% <ø> (-0.07%) ⬇️
appsec-mongoose 49.96% <ø> (-0.07%) ⬇️
appsec-mysql 51.33% <ø> (-0.08%) ⬇️
appsec-node-serialize 43.54% <ø> (-0.09%) ⬇️
appsec-passport 48.15% <ø> (-0.09%) ⬇️
appsec-postgres 51.12% <ø> (-0.08%) ⬇️
appsec-sourcing 42.88% <ø> (-0.09%) ⬇️
appsec-template 43.71% <ø> (-0.09%) ⬇️
appsec-ubuntu 58.55% <100.00%> (-0.06%) ⬇️
appsec-windows 58.39% <100.00%> (-0.09%) ⬇️
instrumentations-instrumentation-bluebird 32.28% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-body-parser 40.75% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.91% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-cookie-parser 34.52% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.86% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.66% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.43% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.88% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 29.78% <100.00%> (+0.01%) ⬆️
instrumentations-instrumentation-http 39.64% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.03% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-mongoose 33.60% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.49% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.30% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-passport 40.79% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport-http 40.76% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport-local 40.76% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-pg 37.81% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise 32.20% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise-js 32.21% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-q 32.26% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-url 32.17% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.23% <ø> (-0.11%) ⬇️
llmobs-ai 41.41% <ø> (-0.10%) ⬇️
llmobs-anthropic 40.62% <ø> (-0.10%) ⬇️
llmobs-bedrock 39.51% <ø> (-0.09%) ⬇️
llmobs-google-genai 40.11% <ø> (-0.09%) ⬇️
llmobs-langchain 39.65% <ø> (-0.19%) ⬇️
llmobs-openai 44.46% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 40.33% <ø> (-0.10%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.62% <ø> (ø)
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.64% <ø> (ø)
plugins-azure-service-bus 22.08% <ø> (ø)
plugins-bullmq 43.60% <ø> (-0.25%) ⬇️
plugins-cassandra 38.05% <ø> (-0.10%) ⬇️
plugins-cookie 23.69% <ø> (ø)
plugins-cookie-parser 23.50% <ø> (ø)
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.42% <ø> (-0.11%) ⬇️
plugins-express-mongo-sanitize 23.67% <ø> (ø)
plugins-express-session 23.46% <ø> (ø)
plugins-fastify 42.56% <ø> (-0.10%) ⬇️
plugins-fetch 38.61% <ø> (-0.10%) ⬇️
plugins-fs 38.68% <ø> (-0.11%) ⬇️
plugins-generic-pool 22.68% <ø> (ø)
plugins-google-cloud-pubsub 45.77% <ø> (-0.09%) ⬇️
plugins-grpc 41.33% <ø> (-0.10%) ⬇️
plugins-handlebars 23.71% <ø> (ø)
plugins-hapi 40.45% <ø> (-0.10%) ⬇️
plugins-hono 40.65% <ø> (-0.10%) ⬇️
plugins-ioredis 38.48% <ø> (-0.11%) ⬇️
plugins-knex 23.51% <ø> (ø)
plugins-ldapjs 21.28% <ø> (ø)
plugins-limitd-client 32.58% <ø> (-0.11%) ⬇️
plugins-lodash 22.74% <ø> (ø)
plugins-mariadb 39.55% <ø> (-0.11%) ⬇️
plugins-memcached 38.21% <ø> (-0.11%) ⬇️
plugins-microgateway-core 39.46% <ø> (-0.10%) ⬇️
plugins-moleculer 40.86% <ø> (-0.10%) ⬇️
plugins-mongodb 39.57% <ø> (-0.10%) ⬇️
plugins-mongodb-core 39.14% <ø> (-0.10%) ⬇️
plugins-mongoose 40.43% <ø> (-0.10%) ⬇️
plugins-multer 23.46% <ø> (ø)
plugins-mysql 39.27% <ø> (-0.11%) ⬇️
plugins-mysql2 39.32% <ø> (-0.10%) ⬇️
plugins-node-serialize 23.73% <ø> (ø)
plugins-opensearch 37.88% <ø> (-0.10%) ⬇️
plugins-postgres 35.71% <100.00%> (-0.08%) ⬇️
plugins-process 22.88% <ø> (ø)
plugins-pug 23.69% <ø> (ø)
plugins-redis 38.81% <ø> (-0.11%) ⬇️
plugins-router 43.28% <ø> (-0.10%) ⬇️
plugins-sequelize 22.27% <ø> (ø)
plugins-test-and-upstream-amqp10 38.55% <ø> (+0.05%) ⬆️
plugins-test-and-upstream-amqplib 43.78% <ø> (-0.25%) ⬇️
plugins-test-and-upstream-apollo 39.34% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.84% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-bunyan 33.87% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-connect 41.07% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.25% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.71% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 39.07% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-rhea 44.22% <ø> (-0.07%) ⬇️
plugins-undici 39.41% <ø> (-0.10%) ⬇️
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.10% <ø> (-0.14%) ⬇️
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.37% <ø> (-0.10%) ⬇️
plugins-ws 40.78% <ø> (-0.10%) ⬇️
profiling-macos 40.07% <ø> (-0.10%) ⬇️
profiling-ubuntu 40.12% <ø> (-0.10%) ⬇️
profiling-windows 41.49% <ø> (-0.10%) ⬇️
serverless-azure-functions-client 22.88% <ø> (ø)
serverless-azure-functions-eventhubs 22.88% <ø> (ø)
serverless-azure-functions-servicebus 22.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 27, 2026

Overall package size

Self size: 4.49 MB
Deduped: 5.33 MB
No deduping: 5.33 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.3 | 76.87 kB | 808.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-official

This comment has been minimized.

@calvinbayer calvinbayer force-pushed the calvin.bayer/feat/SDTEST-2980/create-final-status-tag-for-jest branch 3 times, most recently from 603eda3 to 284540b Compare January 28, 2026 14:46
@calvinbayer calvinbayer marked this pull request as ready for review January 28, 2026 15:21
@calvinbayer calvinbayer requested review from a team as code owners January 28, 2026 15:21
juan-fernandez
juan-fernandez previously approved these changes Jan 28, 2026
Copy link
Copy Markdown
Collaborator

@juan-fernandez juan-fernandez left a comment

Choose a reason for hiding this comment

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

👏 Nice! LGTM other than some minor comments

} else if (shouldFailSometimes) {
assert.ok(!('TEST_HAS_FAILED_ALL_RETRIES' in test.meta))
assert.strictEqual(test.meta[TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED], 'false')
assert.strictEqual(test.meta[TEST_FINAL_STATUS], isQuarantined ? 'skip' : 'fail')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

❓ Does the spec say that if the status is to be ignored because the test is quarantined, its final_status should be skip?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok I see that this is explicitly tested later on, so nvm 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated the test name to be more explicit about the expected state

assert.strictEqual(exitCode, 1)
})

it('sets final_status for quarantined tests', async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
it('sets final_status for quarantined tests', async () => {
it('sets final_status to skip for quarantined tests', async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

}

// For ATR: The last execution's status is what the framework reports
return status
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this function is such a beauty 😄

numberOfExecutedRetries >= (testManagementAttemptToFixRetries + 1)

// When no retry features are active, every test execution is final
const noRetryFeaturesActive = !isEfdEnabled && !isAttemptToFixEnabled
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could we return earlier in this case? (just thinking of ways to simplify this)


// For ATR: The last execution's status is what the framework reports
return status
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm thinking maybe we split the function by feature? So we can understand what each feature does more easily

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@calvinbayer calvinbayer force-pushed the calvin.bayer/feat/SDTEST-2980/create-final-status-tag-for-jest branch from 284540b to 27e9b2a Compare February 2, 2026 10:55
Copy link
Copy Markdown
Collaborator

@juan-fernandez juan-fernandez left a comment

Choose a reason for hiding this comment

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

👏

@calvinbayer calvinbayer merged commit d399d0f into master Feb 2, 2026
787 checks passed
@calvinbayer calvinbayer deleted the calvin.bayer/feat/SDTEST-2980/create-final-status-tag-for-jest branch February 2, 2026 13:53
dd-octo-sts bot pushed a commit that referenced this pull request Feb 3, 2026
…st (#7356)

* feat(test-optimization): create final_status tag on test event for jest

* fix: errors after resolving rebase conflicts

* test: add assertion to test name

* refactor: extract functions to get final state for better readability

* refactor: merge finalStatus function into restuls function for better readability

* fix: efd enabled but not active caused final_status tag to be set on every retry

* style: fix lint violations
@dd-octo-sts dd-octo-sts bot mentioned this pull request Feb 3, 2026
BridgeAR pushed a commit that referenced this pull request Feb 5, 2026
…st (#7356)

* feat(test-optimization): create final_status tag on test event for jest

* fix: errors after resolving rebase conflicts

* test: add assertion to test name

* refactor: extract functions to get final state for better readability

* refactor: merge finalStatus function into restuls function for better readability

* fix: efd enabled but not active caused final_status tag to be set on every retry

* style: fix lint violations
bm1549 pushed a commit that referenced this pull request Feb 10, 2026
…st (#7356)

* feat(test-optimization): create final_status tag on test event for jest

* fix: errors after resolving rebase conflicts

* test: add assertion to test name

* refactor: extract functions to get final state for better readability

* refactor: merge finalStatus function into restuls function for better readability

* fix: efd enabled but not active caused final_status tag to be set on every retry

* style: fix lint violations
BridgeAR pushed a commit that referenced this pull request Feb 22, 2026
…st (#7356)

* feat(test-optimization): create final_status tag on test event for jest

* fix: errors after resolving rebase conflicts

* test: add assertion to test name

* refactor: extract functions to get final state for better readability

* refactor: merge finalStatus function into restuls function for better readability

* fix: efd enabled but not active caused final_status tag to be set on every retry

* style: fix lint violations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants