Skip to content

test: reduce CI flakiness via span-race filters - #8087

Merged
BridgeAR merged 7 commits into
masterfrom
BridgeAR/2026-04-23-fix-flaky-tests
Apr 27, 2026
Merged

test: reduce CI flakiness via span-race filters#8087
BridgeAR merged 7 commits into
masterfrom
BridgeAR/2026-04-23-fix-flaky-tests

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Apr 23, 2026

Copy link
Copy Markdown
Member

A real race fixes that stop assuming traces[0][0] is the span we're looking for across kafkajs, confluentinc-kafka-javascript, redis, ioredis, mariadb, mysql, mysql2, graphql (parse + validate), aws-sdk s3 span-pointers, elasticsearch, opensearch, mongodb-core, pg, prisma, iovalkey, and the IAST testOutsideRequestHasVulnerability and checkVulnerabilityInRequest helpers. Moleculer's startBroker now retries on EADDRINUSE to cover the documented port race, and the rhea before hook finally returns the agent.load promise so mocha actually waits for plugin registration.

@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 5.56 MB
Deduped: 6.4 MB
No deduping: 6.4 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

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

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 23, 2026

Copy link
Copy Markdown

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1 Test failed

with light-my-request >=3 (3.0.0) light-my-request instrumentation "before all" hook in "light-my-request instrumentation" from light-my-request instrumentation   View in Datadog   (Fix with Cursor)
Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/dd-trace-js/dd-trace-js/packages/datadog-instrumentations/test/light-my-request.spec.js)

Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/dd-trace-js/dd-trace-js/packages/datadog-instrumentations/test/light-my-request.spec.js)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 45.74% (-27.87%)

Useful? React with 👍 / 👎

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

@pr-commenter

pr-commenter Bot commented Apr 23, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-04-27 17:04:46

Comparing candidate commit 0b826e7 in PR branch BridgeAR/2026-04-23-fix-flaky-tests with baseline commit 11f5fcc in branch master.

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

@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.79%. Comparing base (11f5fcc) to head (0b826e7).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8087   +/-   ##
=======================================
  Coverage   73.79%   73.79%           
=======================================
  Files         783      783           
  Lines       36369    36369           
=======================================
  Hits        26840    26840           
  Misses       9529     9529           
Flag Coverage Δ
aiguard-macos 36.38% <ø> (-0.09%) ⬇️
aiguard-ubuntu 36.49% <ø> (-0.09%) ⬇️
aiguard-windows 36.29% <ø> (-0.09%) ⬇️
apm-capabilities-tracing-macos 48.14% <ø> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu-active 48.17% <ø> (ø)
apm-capabilities-tracing-ubuntu-latest 48.14% <ø> (ø)
apm-capabilities-tracing-ubuntu-maintenance 48.17% <ø> (ø)
apm-capabilities-tracing-ubuntu-oldest 48.15% <ø> (-0.01%) ⬇️
apm-capabilities-tracing-windows 47.96% <ø> (-0.02%) ⬇️
apm-integrations-child-process 36.03% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-18 34.91% <ø> (-0.22%) ⬇️
apm-integrations-couchbase-eol 35.09% <ø> (-0.09%) ⬇️
apm-integrations-oracledb 35.10% <ø> (-0.09%) ⬇️
appsec-express 52.73% <ø> (-0.08%) ⬇️
appsec-fastify 49.21% <ø> (-0.07%) ⬇️
appsec-graphql 49.50% <ø> (-0.16%) ⬇️
appsec-kafka 41.97% <ø> (-0.09%) ⬇️
appsec-ldapjs 41.31% <ø> (-0.08%) ⬇️
appsec-lodash 41.34% <ø> (-0.08%) ⬇️
appsec-macos 56.75% <ø> (-0.07%) ⬇️
appsec-mongodb-core 45.63% <ø> (-0.07%) ⬇️
appsec-mongoose 46.51% <ø> (-0.07%) ⬇️
appsec-mysql 48.69% <ø> (-0.07%) ⬇️
appsec-node-serialize 40.51% <ø> (-0.08%) ⬇️
appsec-passport 44.52% <ø> (-0.08%) ⬇️
appsec-postgres 48.28% <ø> (-0.07%) ⬇️
appsec-sourcing 40.01% <ø> (-0.08%) ⬇️
appsec-stripe 42.24% <ø> (-0.08%) ⬇️
appsec-template 40.68% <ø> (-0.08%) ⬇️
appsec-ubuntu 56.83% <ø> (-0.07%) ⬇️
appsec-windows 56.63% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-bluebird 29.75% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-body-parser 37.64% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-child_process 35.41% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 31.68% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express 31.90% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.80% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express-session 37.27% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-fs 29.42% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-generic-pool 30.53% <ø> (ø)
instrumentations-instrumentation-http 36.87% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-knex 29.72% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-light-my-request 37.20% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-mongoose 30.82% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-multer 37.41% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-mysql2 35.38% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport 41.17% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-http 40.87% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-local 41.38% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-pg 34.91% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise 29.68% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise-js 29.69% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-q 29.72% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-url 29.68% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-when 29.70% <ø> (-0.10%) ⬇️
llmobs-ai 38.35% <ø> (-0.09%) ⬇️
llmobs-anthropic 37.82% <ø> (-0.09%) ⬇️
llmobs-bedrock 37.06% <ø> (-0.08%) ⬇️
llmobs-google-genai 37.49% <ø> (-0.08%) ⬇️
llmobs-langchain 36.97% <ø> (-0.07%) ⬇️
llmobs-openai 41.18% <ø> (-0.08%) ⬇️
llmobs-vertex-ai 37.67% <ø> (-0.09%) ⬇️
platform-core 30.03% <ø> (ø)
platform-esbuild 32.83% <ø> (ø)
platform-instrumentations-misc 40.01% <ø> (ø)
platform-shimmer 35.72% <ø> (ø)
platform-unit-guardrails 31.39% <ø> (ø)
platform-webpack 20.73% <ø> (ø)
plugins-azure-durable-functions 25.36% <ø> (ø)
plugins-azure-event-hubs 25.51% <ø> (ø)
plugins-azure-service-bus 24.92% <ø> (ø)
plugins-bullmq 40.67% <ø> (+0.02%) ⬆️
plugins-cassandra 35.24% <ø> (-0.09%) ⬇️
plugins-cookie 26.47% <ø> (ø)
plugins-cookie-parser 26.28% <ø> (ø)
plugins-crypto 25.70% <ø> (ø)
plugins-dd-trace-api 35.34% <ø> (-0.09%) ⬇️
plugins-express-mongo-sanitize 26.42% <ø> (ø)
plugins-express-session 26.24% <ø> (ø)
plugins-fastify 39.25% <ø> (-0.09%) ⬇️
plugins-fetch 35.75% <ø> (-0.09%) ⬇️
plugins-fs 35.63% <ø> (-0.10%) ⬇️
plugins-generic-pool 25.40% <ø> (ø)
plugins-google-cloud-pubsub 42.99% <ø> (-0.08%) ⬇️
plugins-grpc 38.01% <ø> (-0.09%) ⬇️
plugins-handlebars 26.46% <ø> (ø)
plugins-hapi 37.25% <ø> (-0.09%) ⬇️
plugins-hono 37.50% <ø> (-0.09%) ⬇️
plugins-ioredis 35.68% <ø> (-0.09%) ⬇️
plugins-knex 26.14% <ø> (ø)
plugins-langgraph 34.98% <ø> (-0.09%) ⬇️
plugins-ldapjs 24.02% <ø> (ø)
plugins-light-my-request 25.88% <ø> (ø)
plugins-limitd-client 29.98% <ø> (-0.09%) ⬇️
plugins-lodash 25.47% <ø> (ø)
plugins-mariadb 36.55% <ø> (-0.09%) ⬇️
plugins-memcached 35.33% <ø> (-0.09%) ⬇️
plugins-microgateway-core 36.34% <ø> (-0.09%) ⬇️
plugins-modelcontextprotocol-sdk 34.27% <ø> (-0.09%) ⬇️
plugins-moleculer 38.03% <ø> (-0.09%) ⬇️
plugins-mongodb 36.61% <ø> (+0.02%) ⬆️
plugins-mongodb-core 36.13% <ø> (-0.09%) ⬇️
plugins-mongoose 36.01% <ø> (-0.17%) ⬇️
plugins-multer 26.24% <ø> (ø)
plugins-mysql 36.42% <ø> (-0.09%) ⬇️
plugins-mysql2 36.40% <ø> (-0.09%) ⬇️
plugins-node-serialize 26.51% <ø> (ø)
plugins-opensearch 35.00% <ø> (-0.09%) ⬇️
plugins-passport-http 26.30% <ø> (ø)
plugins-pino 31.78% <ø> (-0.09%) ⬇️
plugins-postgres 34.39% <ø> (-0.09%) ⬇️
plugins-process 25.70% <ø> (ø)
plugins-pug 26.47% <ø> (ø)
plugins-redis 35.89% <ø> (-0.09%) ⬇️
plugins-router 39.90% <ø> (-0.09%) ⬇️
plugins-sequelize 25.18% <ø> (ø)
plugins-test-and-upstream-amqp10 35.65% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-amqplib 40.83% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-apollo 36.51% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-avsc 35.41% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-bunyan 31.13% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-connect 37.84% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-graphql 37.18% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-koa 37.45% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-protobufjs 35.63% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-rhea 40.90% <ø> (-0.09%) ⬇️
plugins-undici 36.51% <ø> (-0.09%) ⬇️
plugins-url 25.70% <ø> (ø)
plugins-valkey 35.36% <ø> (-0.09%) ⬇️
plugins-vm 25.70% <ø> (ø)
plugins-winston 31.58% <ø> (-0.09%) ⬇️
plugins-ws 38.97% <ø> (-0.09%) ⬇️
profiling-macos 37.82% <ø> (-0.09%) ⬇️
profiling-ubuntu 37.99% <ø> (-0.09%) ⬇️
profiling-windows 39.35% <ø> (-0.09%) ⬇️
serverless-azure-functions-client 25.25% <ø> (ø)
serverless-azure-functions-eventhubs 25.25% <ø> (ø)
serverless-azure-functions-servicebus 25.25% <ø> (ø)

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.

@BridgeAR
BridgeAR marked this pull request as ready for review April 23, 2026 17:35
@BridgeAR
BridgeAR requested review from a team as code owners April 23, 2026 17:35

@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: 0e40bad879

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

Comment thread packages/dd-trace/test/plugins/agent.js Outdated

@wconti27 wconti27 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.

LGTM tho i will let @rochdev be the final approver

@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-04-23-fix-flaky-tests branch from 0e40bad to 215aea4 Compare April 23, 2026 20:35
Comment thread packages/datadog-plugin-moleculer/test/index.spec.js Outdated
Comment thread packages/dd-trace/test/plugins/agent.js Outdated
rochdev
rochdev previously approved these changes Apr 24, 2026
@BridgeAR
BridgeAR marked this pull request as draft April 24, 2026 00:06
@BridgeAR
BridgeAR marked this pull request as draft April 24, 2026 00:06
Caching `checkAgentStatus()` in the test helper removes the dominant
cause of the "Timeout of 5000ms exceeded" hook flakes: without it a
stressed test agent that answers `/info` in a few hundred ms makes
every `beforeEach(agent.load(...))` that slow and the 5 s mocha hook
budget is quickly exhausted. Probing once per worker, gating the
probe on `DD_TEST_AGENT_URL` (set only by `.github/actions/testagent/
start`), and deferring the await to the trace-forwarding handler
unblocks `agent.load()` even when the test agent is slow or
unreachable. Under the same conditions a 20-cycle plugin suite goes
from ~6.4 s to ~0.6 s, and workflows and local runs that don't start
a test agent skip the probe entirely.

Plus real race fixes that stop assuming `traces[0][0]` is the span
we're looking for across kafkajs, confluentinc-kafka-javascript,
redis, ioredis, mariadb, mysql, mysql2, graphql (parse + validate),
aws-sdk s3 span-pointers, elasticsearch, opensearch, mongodb-core,
pg, prisma, iovalkey, and the IAST `testOutsideRequestHasVulnerability`
and `checkVulnerabilityInRequest` helpers. Moleculer's `startBroker`
now retries on EADDRINUSE to cover the documented port race, and the
rhea `before` hook finally returns the `agent.load` promise so mocha
actually waits for plugin registration.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-04-23-fix-flaky-tests branch from 542f0be to e8d8308 Compare April 27, 2026 16:52
@BridgeAR BridgeAR changed the title test: reduce CI flakiness via probe cache and span-race filters test: reduce CI flakiness via span-race filters Apr 27, 2026
@BridgeAR
BridgeAR marked this pull request as ready for review April 27, 2026 16:56
@BridgeAR

Copy link
Copy Markdown
Member Author

I limited this to span race filters and I move the agent changes to a separate PR

agent.assertSomeTraces(traces => {
try {
const span = traces[0][0]
const span = traces[0].find(s => s.meta?.['aws.operation'] === 'putObject')

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.

all changes look good to me, tho im wondering if we should consider a helper function for matching the correct span assertion?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think that makes sense, yes.
We have something like that already and improving our current mechanism is good!
That way the tests would generally run a tad faster because we generate less intermediate errors.

Right now, I would land it as is as stop gap.

@CarlesDD CarlesDD 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.

LGTM from IAST prespective

@BridgeAR
BridgeAR merged commit 4cefbaf into master Apr 27, 2026
1168 of 1175 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-04-23-fix-flaky-tests branch April 27, 2026 22:04
dd-octo-sts Bot pushed a commit that referenced this pull request Apr 28, 2026
This addresses real span race conditions. Assuming `traces[0][0]` is the
span we're looking for across kafkajs, confluentinc-kafka-javascript,
redis, ioredis, mariadb, mysql, mysql2, graphql (parse + validate),
aws-sdk s3 span-pointers, elasticsearch, opensearch, mongodb-core,
pg, prisma, iovalkey, and the IAST `testOutsideRequestHasVulnerability`
and `checkVulnerabilityInRequest` helpers is not always correct.
Moleculer's `startBroker` now prevents the port race by using the the
zero port, and the rhea `before` hook finally returns the `agent.load`
promise so mocha actually waits for plugin registration.
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Apr 28, 2026
BridgeAR added a commit that referenced this pull request Apr 30, 2026
This addresses real span race conditions. Assuming `traces[0][0]` is the
span we're looking for across kafkajs, confluentinc-kafka-javascript,
redis, ioredis, mariadb, mysql, mysql2, graphql (parse + validate),
aws-sdk s3 span-pointers, elasticsearch, opensearch, mongodb-core,
pg, prisma, iovalkey, and the IAST `testOutsideRequestHasVulnerability`
and `checkVulnerabilityInRequest` helpers is not always correct.
Moleculer's `startBroker` now prevents the port race by using the the
zero port, and the rhea `before` hook finally returns the `agent.load`
promise so mocha actually waits for plugin registration.
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.

4 participants