Skip to content

feat(test-optimization): correlate WebdriverIO tests with RUM - #10049

Draft
juan-fernandez wants to merge 12 commits into
juan-fernandez/orchestrion-async-context-callbacksfrom
juan-fernandez/wdio-rum-correlation
Draft

feat(test-optimization): correlate WebdriverIO tests with RUM#10049
juan-fernandez wants to merge 12 commits into
juan-fernandez/orchestrion-async-context-callbacksfrom
juan-fernandez/wdio-rum-correlation

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds WebdriverIO 9 RUM session-to-test correlation for the Mocha and Jasmine adapters.

The instrumentation:

  • Detects RUM after navigation and adds the test execution ID cookie.
  • Adds browser metadata to the active test span.
  • Preserves correlation across retries and already-open pages.
  • Stops and flushes RUM after the user's afterEach hook.
  • Cleans retained state before the next test when no afterEach hook runs.
  • Cleans remaining state before WebdriverIO deletes the browser session.

The browser operations use normal async functions that return promises. Existing Orchestrion completion callbacks wait
for those promises before the instrumented WebdriverIO function continues or settles.

Motivation

Bring WebdriverIO to parity with the existing Playwright and Cypress RUM/test correlation behavior without requiring a
WebdriverIO service or user configuration.

Additional Notes

This is the upper PR in a two-PR stack:

  1. feat(instrumentation): add async Orchestrion context callbacks #10080 adds the two generic Orchestrion callback options.
  2. This PR contains the WebdriverIO- and RUM-specific implementation.

Both PRs are drafts. Merge #10080 before rebasing this PR onto master.

Verification:

  • ./node_modules/.bin/mocha packages/datadog-instrumentations/test/helpers/rewriter/index.spec.js — 36 passing
  • ./node_modules/.bin/mocha packages/datadog-instrumentations/test/webdriverio.spec.js — 58 passing
  • ./node_modules/.bin/mocha --timeout 60000 integration-tests/webdriverio/webdriverio.test-optimization.spec.js — 146 passing, 24 pending
  • Every commit in both branches has a valid SSH signature.

@juan-fernandez

Copy link
Copy Markdown
Collaborator 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: 97318a9a55

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
@pr-commenter

pr-commenter Bot commented Aug 28, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-31 17:56:02

Comparing candidate commit 5a4323c in PR branch juan-fernandez/wdio-rum-correlation with baseline commit 48242b7 in branch juan-fernandez/orchestrion-async-context-callbacks.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2299 metrics, 11 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:dogstatsd-with-tags-20

  • unstable cpu_user_time [-336.600ms; +403.522ms] or [-6.743%; +8.084%]
  • unstable execution_time [-337.514ms; +399.428ms] or [-6.655%; +7.876%]
  • unstable throughput [-132070.171op/s; +114960.689op/s] or [-7.975%; +6.942%]

scenario:llmobs-encode-unicode-mixed-20

  • unstable max_rss_usage [-12.082MB; +5.446MB] or [-15.197%; +6.850%]

scenario:log-with-debug-20

  • unstable max_rss_usage [-8.421MB; +4.909MB] or [-7.334%; +4.276%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable cpu_usage_percentage [-9.414%; +2.074%]
  • unstable cpu_user_time [-4.886ms; +2.157ms] or [-8.151%; +3.599%]
  • unstable execution_time [-4197.055µs; +2513.055µs] or [-6.767%; +4.052%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-3.666MB; +10.274MB] or [-2.931%; +8.216%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable max_rss_usage [-8.481MB; +11.529MB] or [-5.839%; +7.937%]

scenario:plugin-pg-service-24

  • unstable execution_time [-82.404ms; +109.847ms] or [-4.946%; +6.594%]

@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/wdio-rum-correlation branch from 97318a9 to 33751bd Compare August 28, 2026 15:29
@dd-octo-sts

dd-octo-sts Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.66 MB
Deduped: 9.32 MB
No deduping: 9.32 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.4.0 | 127.33 kB | 447.04 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

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

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Aug 28, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 3 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-js | benchmark: [26, 3] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

Project | lint — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

8 linting errors: Unexpected await inside a loop found on multiple lines.

All Green | all-green

View more details · View in GitHub Actions

Error occurred during the request with Octokit library, likely a request error.

📋 Copy fix prompt
CI on my pull request is failing. Help me find and fix the root cause of each failing job below — they were flagged as caused by changes in this PR, so focus on the diff. For each job, explain the failure and propose a fix.

Before you start, set up the Datadog software-delivery tooling so you can
query the CI data yourself:

1. Check whether you already have the Datadog software-delivery MCP tools
   (e.g. a `search_datadog_ci_pipeline_events` tool) and the `unblock-pr` skill.
2. If either is missing, STOP and ask me for permission before installing
   anything. Do not install or run anything until I have said yes.
3. Only with my explicit approval, set up the Datadog software-delivery MCP
   server and skills by following:
     https://docs.datadoghq.com/getting_started/software_delivery_mcp_tools/
   then restart so the skill is picked up.
4. If I decline, skip all of the above and work from the context below alone.

Then run /unblock-pr — it will pull the CI data itself. The job context below is what we already know.

If /unblock-pr is not available — because I declined the setup above, or it did not install — work from the context below instead.

Datadog has already classified this failure as caused by changes in this PR.
Take that as given and work the fix:

1. Locate the change. Diff this branch against its base and find the change
   that produces this error. Explain the mechanism, don't just name a file:
     git fetch origin && git diff $(git merge-base origin/juan-fernandez/orchestrion-async-context-callbacks HEAD)...HEAD
2. Reproduce it locally. Run the failing job's command or test before
   proposing anything.
3. Propose the smallest fix that addresses the root cause — not a workaround,
   not a broadened assertion, not a disabled or skipped test.
4. Re-run the same command to confirm, and say exactly what you ran.
5. If the failure turns out to be intermittent rather than deterministic, say
   so plainly instead of "fixing" it — that is a flaky test, and patching it
   hides the problem.

If the right move is to re-run the job rather than change code, use the job
link in the context below. For GitHub Actions: `gh run rerun <run-id> --failed`,
where the run ID is the number after `/runs/` in that URL (not the trailing
number, which is the job ID).

Branch: juan-fernandez/wdio-rum-correlation

Project | lint
Commit: 59ecb8379ef8f8e160b89b6fb47da6d31792f592
Error (code / quality):
8 linting errors: Unexpected `await` inside a loop found on multiple lines.
CI job: https://github.com/DataDog/dd-trace-js/actions/runs/33440410615/job/99647938488

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 53.43%
Overall Coverage: 97.27% (-1.36%)

Useful? React with 👍 / 👎

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

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.49144% with 353 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.25%. Comparing base (eab5edc) to head (d73b378).

Files with missing lines Patch % Lines
...ckages/datadog-instrumentations/src/webdriverio.js 41.90% 330 Missing ⚠️
packages/datadog-plugin-mocha/src/index.js 37.83% 23 Missing ⚠️
Additional details and impacted files
@@                                  Coverage Diff                                   @@
##           juan-fernandez/orchestrion-async-context-callbacks   #10049      +/-   ##
======================================================================================
+ Coverage                                               91.38%   97.25%   +5.87%     
======================================================================================
  Files                                                     882      996     +114     
  Lines                                                  137878   152786   +14908     
  Branches                                                12110    12286     +176     
======================================================================================
+ Hits                                                   125994   148598   +22604     
+ Misses                                                  11884     4188    -7696     
Flag Coverage Δ
aiguard 63.27% <100.00%> (+0.15%) ⬆️
aiguard-integration 59.13% <100.00%> (+0.13%) ⬆️
apm-bucket-0 62.63% <100.00%> (+0.14%) ⬆️
apm-bucket-1 68.03% <100.00%> (+0.11%) ⬆️
apm-bucket-2 67.60% <100.00%> (+0.12%) ⬆️
apm-bucket-3 64.47% <100.00%> (+0.13%) ⬆️
apm-capabilities-tracing 62.60% <86.31%> (?)
apm-integrations-aerospike 60.65% <100.00%> (+0.16%) ⬆️
apm-integrations-confluentinc-kafka-javascript 66.74% <100.00%> (+0.17%) ⬆️
apm-integrations-couchbase 61.16% <100.00%> (+0.15%) ⬆️
apm-integrations-http 66.32% <100.00%> (+0.11%) ⬆️
apm-integrations-kafkajs 67.32% <100.00%> (+0.13%) ⬆️
apm-integrations-next 63.96% <100.00%> (?)
apm-integrations-prisma 62.01% <100.00%> (+0.13%) ⬆️
appsec 76.78% <100.00%> (?)
appsec-express_fastify_graphql 72.74% <100.00%> (+0.07%) ⬆️
appsec-integration 49.54% <53.09%> (+0.01%) ⬆️
appsec-kafka_ldapjs_lodash 67.53% <100.00%> (+0.11%) ⬆️
appsec-mongodb-core_mongoose_mysql 70.71% <100.00%> (+0.09%) ⬆️
appsec-next 57.24% <100.00%> (+0.12%) ⬆️
appsec-node-serialize_passport_postgres 70.17% <100.00%> (+0.09%) ⬆️
appsec-sourcing_stripe_template 68.61% <100.00%> (+0.09%) ⬆️
debugger 69.15% <100.00%> (?)
instrumentations-bucket-0 56.25% <100.00%> (?)
instrumentations-bucket-1 64.28% <100.00%> (?)
instrumentations-bucket-10 53.46% <100.00%> (?)
instrumentations-bucket-11 65.72% <100.00%> (?)
instrumentations-bucket-12 61.53% <100.00%> (?)
instrumentations-bucket-13 56.44% <100.00%> (?)
instrumentations-bucket-14 55.89% <100.00%> (?)
instrumentations-bucket-2 57.08% <100.00%> (?)
instrumentations-bucket-3 57.28% <100.00%> (?)
instrumentations-bucket-4 63.90% <100.00%> (?)
instrumentations-bucket-5 56.69% <100.00%> (+0.18%) ⬆️
instrumentations-bucket-6 58.24% <100.00%> (+0.14%) ⬆️
instrumentations-bucket-7 65.77% <100.00%> (+0.13%) ⬆️
instrumentations-bucket-8 63.05% <100.00%> (+0.14%) ⬆️
instrumentations-bucket-9 64.63% <100.00%> (+0.13%) ⬆️
instrumentations-instrumentation-couchbase 54.87% <100.00%> (+0.20%) ⬆️
instrumentations-instrumentation-zlib 55.93% <100.00%> (+0.19%) ⬆️
instrumentations-integration-esbuild 34.70% <53.09%> (+0.19%) ⬆️
llmobs-ai_anthropic_bedrock 66.77% <100.00%> (?)
llmobs-bucket-1 64.91% <100.00%> (?)
llmobs-openai 66.80% <100.00%> (?)
llmobs-openai-agents_vertex-ai 64.03% <100.00%> (+0.06%) ⬆️
llmobs-sdk 75.98% <100.00%> (+0.10%) ⬆️
master-coverage ?
openfeature 59.73% <100.00%> (+0.15%) ⬆️
openfeature-unit 58.42% <100.00%> (?)
platform-core_esbuild_instrumentations-misc 41.19% <53.09%> (?)
platform-integration 64.91% <100.00%> (?)
platform-shimmer_unit-guardrails_webpack 39.03% <53.09%> (+0.12%) ⬆️
plugins-browser-bunyan_bullmq_cassandra 66.34% <100.00%> (+0.13%) ⬆️
plugins-bucket-0 61.04% <100.00%> (+0.13%) ⬆️
plugins-bucket-1 ?
plugins-bucket-11 66.18% <100.00%> (-1.48%) ⬇️
plugins-bucket-17 66.55% <100.00%> (?)
plugins-bucket-18 66.04% <100.00%> (+0.62%) ⬆️
plugins-bucket-19 68.48% <100.00%> (+3.58%) ⬆️
plugins-bucket-20 69.22% <100.00%> (+0.59%) ⬆️
plugins-bucket-4 61.22% <100.00%> (?)
plugins-cookie_cookie-parser_crypto 55.85% <100.00%> (+0.19%) ⬆️
plugins-fastify_fetch_fs 65.47% <100.00%> (?)
plugins-generic-pool_google-cloud-pubsub_grpc 69.02% <100.00%> (?)
plugins-handlebars_hapi_hono 63.71% <100.00%> (+0.14%) ⬆️
plugins-ioredis_langgraph_ldapjs 61.66% <100.00%> (?)
plugins-ldapjs_light-my-request_limitd-client ?
plugins-light-my-request_limitd-client_lodash 63.56% <100.00%> (?)
plugins-lodash_mariadb_memcached ?
plugins-mariadb_memcached_mercurius 67.95% <100.00%> (?)
plugins-moleculer_mongodb_mongodb-core ?
plugins-mongodb_mongodb-core_mongoose 64.14% <100.00%> (?)
plugins-multer_mysql_mysql2 63.80% <100.00%> (?)
plugins-nats_node-serialize_opensearch 65.65% <100.00%> (?)
plugins-opensearch_passport-http_pino ?
plugins-passport-http_pino_postgres 63.51% <100.00%> (?)
plugins-postgres_process_pug ?
plugins-process_pug_redis 62.32% <100.00%> (?)
plugins-redis_router_sequelize ?
plugins-test-and-upstream-rhea_undici_url ?
plugins-undici_url_valkey 62.57% <100.00%> (?)
plugins-valkey_vm_winston ?
plugins-vm_winston_ws 64.83% <100.00%> (?)
profiling 66.29% <100.00%> (+0.12%) ⬆️
serverless-aws-sdk-aws-sdk 55.54% <100.00%> (+0.14%) ⬆️
serverless-aws-sdk-base-inject-field 55.42% <100.00%> (+0.19%) ⬆️
serverless-aws-sdk-bedrockruntime 58.39% <100.00%> (+0.15%) ⬆️
serverless-aws-sdk-client 60.17% <100.00%> (+0.14%) ⬆️
serverless-aws-sdk-dynamodb 59.25% <100.00%> (+0.13%) ⬆️
serverless-aws-sdk-eventbridge 57.74% <100.00%> (+0.13%) ⬆️
serverless-aws-sdk-kinesis 63.21% <100.00%> (+0.13%) ⬆️
serverless-aws-sdk-lambda 61.18% <100.00%> (+0.13%) ⬆️
serverless-aws-sdk-s3 59.30% <100.00%> (+0.14%) ⬆️
serverless-aws-sdk-serverless-peer-service 63.78% <100.00%> (+0.13%) ⬆️
serverless-aws-sdk-sns 64.09% <100.00%> (+0.12%) ⬆️
serverless-aws-sdk-sqs 64.55% <100.00%> (+0.12%) ⬆️
serverless-aws-sdk-stepfunctions 59.16% <100.00%> (?)
serverless-aws-sdk-util 56.04% <100.00%> (+0.19%) ⬆️
serverless-bucket-0 57.93% <100.00%> (?)
serverless-bucket-1 63.79% <100.00%> (?)
test-optimization-cucumber 70.57% <87.89%> (+0.06%) ⬆️
test-optimization-cypress 64.80% <87.89%> (+0.08%) ⬆️
test-optimization-jest 72.10% <87.89%> (+0.05%) ⬆️
test-optimization-mocha 71.99% <87.89%> (+0.05%) ⬆️
test-optimization-playwright-playwright-atr 59.87% <87.95%> (+0.10%) ⬆️
test-optimization-playwright-playwright-efd 60.50% <87.95%> (+0.09%) ⬆️
test-optimization-playwright-playwright-final-status 60.11% <87.95%> (+0.10%) ⬆️
test-optimization-playwright-playwright-impacted-tests 60.22% <87.95%> (+0.10%) ⬆️
test-optimization-playwright-playwright-reporting 61.19% <87.95%> (?)
test-optimization-playwright-playwright-test-management 60.53% <87.95%> (-0.65%) ⬇️
test-optimization-playwright-playwright-test-span 59.87% <87.95%> (?)
test-optimization-selenium 58.94% <87.89%> (?)
test-optimization-testopt ?
test-optimization-vitest 72.70% <87.89%> (+0.05%) ⬆️
test-optimization-vitest-browser 58.77% <87.95%> (?)
test-optimization-webdriverio ?

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

☔ View full report in Codecov by Harness.
📢 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.

@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/wdio-rum-correlation branch from 33751bd to 633880e Compare August 30, 2026 06:52
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 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-08-31T11:53:42.165664Z f918bcc New commits
ℹ️ 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.

@juan-fernandez
juan-fernandez marked this pull request as ready for review August 30, 2026 09:55
@juan-fernandez
juan-fernandez requested review from a team as code owners August 30, 2026 09:55

@datadog-prod-us1-4 datadog-prod-us1-4 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.

Datadog Autotest: FAIL

The RUM cleanup records only the WebdriverIO browser object. Tests that use more than one window or origin can keep an old correlation cookie and can link later RUM events to the wrong test.

Open Bits AI session

🤖 Datadog Autotest · Commit 633880e · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated

@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: 633880e8fd

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review
/datadog autotest 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: 1b02272c73

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/rum-browser-scripts.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

/datadog autotest 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: 8e03228f5c

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated

@datadog-prod-us1-4 datadog-prod-us1-4 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.

Datadog Autotest: FAIL

A test that uses one browser window for more than one origin leaves the old origin's correlation cookie. A later test can send RUM data with the prior test execution ID.

Open Bits AI session

🤖 Datadog Autotest · Commit 8e03228 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

/datadog autotest review

@datadog-prod-us1-4 datadog-prod-us1-4 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.

Datadog Autotest: PASS

More details

This PR adds WebdriverIO 9 RUM-to-test correlation for Mocha and Jasmine;
it detects RUM after navigation, sets the test cookie and browser tags,
and stops and flushes RUM after hooks and before retries.
The new commit tracks every visited origin and removes its cookie,
so it fixes the earlier stale-cookie issue; no issue remains open.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 265c53c · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@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: 265c53c1e4

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated

@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: fb94d6b7f4

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator 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: 1e4c5245ad

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator 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: ab91b5d16d

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-plugin-mocha/src/index.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/test/webdriverio.spec.js Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator 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: 4bc6b2022d

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js
Comment thread packages/datadog-instrumentations/src/webdriverio.js
Comment thread packages/datadog-instrumentations/src/webdriverio.js Fixed

@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: 8f89af0bf3

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/helpers/rewriter/transforms.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-instrumentations/src/webdriverio.js Outdated
Comment thread packages/datadog-plugin-mocha/src/index.js Outdated
@juan-fernandez
juan-fernandez marked this pull request as draft August 31, 2026 11:50

@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: f918bcc386

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

typeof browser.scriptAddPreloadScript !== 'function') return

try {
if (rumBrowserPreloadScripts.has(browser)) return

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 Refresh the preload when retry IDs rotate

When a BiDi test enters a native WebdriverIO retry and then navigates, the retry path reapplies the new execution ID to the current windows, but this early return preserves the preload script whose serialized argument still contains the previous attempt's ID. The next document executes that stale preload before RUM initializes, so its initial RUM events are associated with the prior attempt even if post-navigation cookie setting later corrects the ID. Fresh evidence after the earlier retry fix is that the final retry test explicitly keeps scriptAddPreloadScript at one call while changing IDs and never loads a subsequent document; replace the preload when its execution ID changes and exercise the resulting document lifecycle.

AGENTS.md reference: AGENTS.md:L129-L129

Useful? React with 👍 / 👎.

const hookName = context.arguments?.[7]
if (!isRumCleanupPending || (type === 'Hook' && hookName === 'afterEach')) return

context.rumCleanupGenerator = cleanupRumBrowsers

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 Clean the prior RUM session before binding the next test

For a Jasmine suite without afterEach, this defers cleanup until the next test or hook wrapper has started, at which point the tracing start channel has already bound the new test's store. If the previous RUM session is active, cleanupRumWindow publishes getRumTestExecutionId(browser, true) during that cleanup, causing the Mocha plugin to mark the new test as RUM-active and attach browser metadata even if it never uses RUM. Run the guaranteed cleanup before binding the next test span or preserve the prior test context; the current regression stubs stopRumSession to return false, so it does not assert the real span metadata affected here.

AGENTS.md reference: AGENTS.md:L129-L129

Useful? React with 👍 / 👎.

Comment on lines +567 to +569
} else if (type === 'Hook' && hookName === 'afterEach') {
context.resolveGenerator = cleanupRumBrowsers
context.rejectGenerator = cleanupRumBrowsers

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 Defer cleanup until the final afterEach wrapper

When a framework invokes two afterEach hook wrappers, such as hooks from nested suites or a shared helper plus the suite, the first wrapper's completion enters this branch and stops RUM, removes the preload, and deletes the cookie. A later afterEach that interacts with the same page then runs without correlation because the browser has already been removed from the active set and no navigation occurs to register it again. Fresh evidence after the earlier single-hook fix is that this final condition accepts every individual afterEach wrapper and has no signal that the current one is the last; move cleanup to a lifecycle after all such hooks have completed.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.

Comment on lines +195 to +197
rumBrowsers.add(browser)
rumCorrelationBrowsers.add(browser)
rumBrowserTestExecutionIds.set(browser, testExecutionId)

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 Do not mark sampled-out BiDi sessions active

When a BiDi page loads the RUM SDK but its session is sampled out, this pre-navigation registration keeps the browser in rumCorrelationBrowsers even though post-navigation detection correctly reports isRumActive: false. Cleanup later executes stopRumSession, whose return value is based only on the presence of the SDK's stopSession method, and therefore calls getRumTestExecutionId(browser, true), incorrectly emitting test.is_rum_active=true and waiting for a nonexistent active session. Track whether detection actually found an active session rather than treating every preloaded browser as active; the sampled-out regression currently exercises only the classic path, not this BiDi sibling.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.

@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/wdio-rum-correlation branch from f918bcc to dc64c5d Compare August 31, 2026 17:37
@juan-fernandez
juan-fernandez changed the base branch from master to juan-fernandez/orchestrion-async-context-callbacks August 31, 2026 17:38
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/orchestrion-async-context-callbacks branch from 6d983fb to 48242b7 Compare August 31, 2026 17:43
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/wdio-rum-correlation branch from dc64c5d to 5a4323c Compare August 31, 2026 17:43
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/orchestrion-async-context-callbacks branch from 48242b7 to eab5edc Compare August 31, 2026 21:15
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/wdio-rum-correlation branch from 5a4323c to d73b378 Compare August 31, 2026 21:15
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