Skip to content

test(mongodb): await traced operations - #9822

Open
BridgeAR wants to merge 4 commits into
masterfrom
BridgeAR/2026-08-14-mongodb-core-trace-flake
Open

test(mongodb): await traced operations#9822
BridgeAR wants to merge 4 commits into
masterfrom
BridgeAR/2026-08-14-mongodb-core-trace-flake

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

MongoDB query spans finish from the driver callback or returned promise. Thirty-one tests discarded that completion signal and waited only for the mock-agent trace, so slow operations could hit the default one-second deadline before span completion. The same pattern also hid driver rejections behind trace timeouts.

Await each operation and trace together, use the existing two-second Mongo trace allowance, and build BSON fixtures with the active driver where MongoDB 5 and newer reject BSON values from an older package.

DBM propagation traces finish from the driver callback, but these tests discarded that callback and failed after the agent's 1s deadline when the operation ran slowly. Await the operation alongside the trace so backend errors surface, and give trace delivery the same 2s allowance already used by MongoDB tests.

Refs: https://github.com/DataDog/dd-trace-js/actions/runs/31803050571/job/94775323451?pr=9633
MongoDB query spans finish from driver callbacks or returned promises, but the remaining trace assertions discarded that operation completion. Await both boundaries so slow operations receive the suite's existing two-second allowance and unexpected backend errors fail their owning test.

Keep command completion and BSON fixtures aligned with the driver versions whose results are now observed. This is test-only; production code is unchanged.
@dd-octo-sts

dd-octo-sts Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.2 MB
Deduped: 8.86 MB
No deduping: 8.86 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.3 | 125.43 kB | 441.72 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 14, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 98.53% (+0.00%)

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

@pr-commenter

pr-commenter Bot commented Aug 14, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-14 19:19:22

Comparing candidate commit 4717f90 in PR branch BridgeAR/2026-08-14-mongodb-core-trace-flake with baseline commit 942f9f8 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2282 metrics, 10 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:appsec-appsec-enabled-20

  • unstable max_rss_usage [-21.257MB; +32.483MB] or [-11.774%; +17.992%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-24.729MB; +21.893MB] or [-6.450%; +5.711%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable max_rss_usage [-16207.599KB; +15613.999KB] or [-6.595%; +6.353%]

scenario:debugger-line-probe-without-snapshot-20

  • unstable max_rss_usage [-8.623MB; +16.004MB] or [-4.483%; +8.321%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable max_rss_usage [-7.496MB; +21.116MB] or [-2.644%; +7.449%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-437.999ms; +203.872ms] or [-9.190%; +4.278%]
  • unstable execution_time [-437.175ms; +209.005ms] or [-9.035%; +4.319%]
  • unstable throughput [-74143.122op/s; +154225.291op/s] or [-4.275%; +8.892%]

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

  • unstable max_rss_usage [-23.867MB; +44.207MB] or [-6.088%; +11.276%]

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

  • unstable max_rss_usage [-8.409MB; +5.318MB] or [-6.438%; +4.072%]

MongoDB changes command-rejection messages and codes between server versions while trace behavior stays the same. Matching server-owned prose made these tests fail before they could validate tracing.
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.53%. Comparing base (942f9f8) to head (4717f90).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #9822    +/-   ##
========================================
  Coverage   98.53%   98.53%            
========================================
  Files         975      975            
  Lines      144148   144148            
  Branches    12475    13020   +545     
========================================
  Hits       142031   142031            
  Misses       2117     2117            
Flag Coverage Δ
aiguard 57.23% <ø> (-0.03%) ⬇️
aiguard-integration 55.49% <ø> (ø)
apm-bucket-0 57.63% <ø> (-0.03%) ⬇️
apm-bucket-1 62.82% <ø> (-0.02%) ⬇️
apm-bucket-2 61.65% <ø> (-0.03%) ⬇️
apm-bucket-3 59.27% <ø> (-0.03%) ⬇️
apm-capabilities-tracing 62.35% <ø> (ø)
apm-integrations-aerospike 55.52% <ø> (-0.03%) ⬇️
apm-integrations-confluentinc-kafka-javascript 60.63% <ø> (+<0.01%) ⬆️
apm-integrations-couchbase 56.21% <ø> (-0.03%) ⬇️
apm-integrations-http 61.38% <ø> (-0.02%) ⬇️
apm-integrations-kafkajs 61.15% <ø> (-0.03%) ⬇️
apm-integrations-next 58.89% <ø> (-0.03%) ⬇️
apm-integrations-prisma 58.33% <ø> (-0.02%) ⬇️
appsec 71.49% <ø> (-0.02%) ⬇️
appsec-express_fastify_graphql 68.91% <ø> (-0.02%) ⬇️
appsec-integration 49.60% <ø> (ø)
appsec-kafka_ldapjs_lodash 62.88% <ø> (-0.02%) ⬇️
appsec-mongodb-core_mongoose_mysql 66.37% <ø> (-0.02%) ⬇️
appsec-next 56.24% <ø> (-0.02%) ⬇️
appsec-node-serialize_passport_postgres 65.78% <ø> (-0.02%) ⬇️
appsec-sourcing_stripe_template 64.21% <ø> (-0.02%) ⬇️
debugger 63.67% <ø> (-0.01%) ⬇️
instrumentations-bucket-0 51.24% <ø> (-0.03%) ⬇️
instrumentations-bucket-1 59.13% <ø> (-0.03%) ⬇️
instrumentations-bucket-10 60.39% <ø> (-0.02%) ⬇️
instrumentations-bucket-11 61.05% <ø> (-0.02%) ⬇️
instrumentations-bucket-12 51.15% <ø> (-0.03%) ⬇️
instrumentations-bucket-13 52.00% <ø> (-0.03%) ⬇️
instrumentations-bucket-14 51.26% <ø> (-0.03%) ⬇️
instrumentations-bucket-2 52.49% <ø> (-0.03%) ⬇️
instrumentations-bucket-3 53.13% <ø> (-0.03%) ⬇️
instrumentations-bucket-4 58.21% <ø> (-0.03%) ⬇️
instrumentations-bucket-5 48.82% <ø> (-0.02%) ⬇️
instrumentations-bucket-6 59.74% <ø> (-0.03%) ⬇️
instrumentations-bucket-7 51.44% <ø> (-0.03%) ⬇️
instrumentations-bucket-8 57.92% <ø> (-0.02%) ⬇️
instrumentations-bucket-9 56.75% <ø> (-0.03%) ⬇️
instrumentations-instrumentation-couchbase 50.22% <ø> (-0.03%) ⬇️
instrumentations-integration-esbuild 33.87% <ø> (ø)
llmobs-ai_anthropic_bedrock 62.31% <ø> (-0.02%) ⬇️
llmobs-bucket-1 60.84% <ø> (-0.02%) ⬇️
llmobs-openai 61.25% <ø> (-0.02%) ⬇️
llmobs-openai-agents_vertex-ai 59.55% <ø> (-0.02%) ⬇️
llmobs-sdk 67.23% <ø> (-0.03%) ⬇️
master-coverage 98.53% <ø> (?)
openfeature 55.19% <ø> (ø)
openfeature-unit 52.84% <ø> (-0.03%) ⬇️
platform-core_esbuild_instrumentations-misc 40.85% <ø> (-0.02%) ⬇️
platform-integration 59.92% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 38.49% <ø> (-0.02%) ⬇️
plugins-bucket-0 56.43% <ø> (-0.02%) ⬇️
plugins-bucket-1 53.55% <ø> (ø)
plugins-bucket-11 60.93% <ø> (-0.03%) ⬇️
plugins-bucket-17 60.75% <ø> (-0.03%) ⬇️
plugins-bucket-18 61.42% <ø> (-0.02%) ⬇️
plugins-bucket-19 60.78% <ø> (-0.03%) ⬇️
plugins-bucket-20 63.15% <ø> (-0.03%) ⬇️
plugins-bucket-4 57.81% <ø> (-0.03%) ⬇️
plugins-bullmq_cassandra_cookie 60.84% <ø> (-0.03%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 55.86% <ø> (-0.03%) ⬇️
plugins-fetch_fs_generic-pool 57.72% <ø> (-0.06%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 63.59% <ø> (-0.02%) ⬇️
plugins-hapi_hono_ioredis 59.38% <ø> (-0.03%) ⬇️
plugins-knex_langgraph_ldapjs 54.60% <ø> (-0.03%) ⬇️
plugins-light-my-request_limitd-client_lodash 57.86% <ø> (-0.03%) ⬇️
plugins-mariadb_memcached_mercurius 61.02% <ø> (-0.02%) ⬇️
plugins-mongodb_mongodb-core_mongoose 58.75% <ø> (-0.03%) ⬇️
plugins-multer_mysql_mysql2 58.34% <ø> (-0.03%) ⬇️
plugins-nats_node-serialize_opensearch 59.86% <ø> (-0.03%) ⬇️
plugins-passport-http_pino_postgres 58.08% <ø> (-0.03%) ⬇️
plugins-process_pug_redis 56.89% <ø> (-0.03%) ⬇️
plugins-undici_url_valkey 57.51% <ø> (-0.06%) ⬇️
plugins-vm_winston_ws 59.07% <ø> (-0.03%) ⬇️
profiling 61.16% <ø> (-0.02%) ⬇️
serverless-aws-sdk-aws-sdk 54.40% <ø> (-0.02%) ⬇️
serverless-aws-sdk-base-inject-field 50.47% <ø> (-0.03%) ⬇️
serverless-aws-sdk-bedrockruntime 54.19% <ø> (-0.02%) ⬇️
serverless-aws-sdk-client 55.71% <ø> (-0.03%) ⬇️
serverless-aws-sdk-dynamodb 55.01% <ø> (-0.03%) ⬇️
serverless-aws-sdk-eventbridge 56.49% <ø> (-0.02%) ⬇️
serverless-aws-sdk-kinesis 58.55% <ø> (-0.02%) ⬇️
serverless-aws-sdk-lambda 56.73% <ø> (-0.02%) ⬇️
serverless-aws-sdk-s3 55.11% <ø> (-0.02%) ⬇️
serverless-aws-sdk-serverless-peer-service 59.13% <ø> (-0.02%) ⬇️
serverless-aws-sdk-sns 59.34% <ø> (-0.02%) ⬇️
serverless-aws-sdk-sqs 59.75% <ø> (-0.02%) ⬇️
serverless-aws-sdk-stepfunctions 54.94% <ø> (-0.02%) ⬇️
serverless-aws-sdk-util 50.99% <ø> (-0.03%) ⬇️
serverless-bucket-0 53.35% <ø> (ø)
serverless-bucket-1 58.36% <ø> (-0.03%) ⬇️
test-optimization-cucumber 70.59% <ø> (+0.01%) ⬆️
test-optimization-cypress 64.74% <ø> (+0.03%) ⬆️
test-optimization-jest 71.98% <ø> (-0.01%) ⬇️
test-optimization-mocha 72.05% <ø> (+0.04%) ⬆️
test-optimization-playwright-playwright-atr 59.52% <ø> (-0.02%) ⬇️
test-optimization-playwright-playwright-efd 59.67% <ø> (-0.01%) ⬇️
test-optimization-playwright-playwright-final-status 59.83% <ø> (-0.02%) ⬇️
test-optimization-playwright-playwright-impacted-tests 59.46% <ø> (+0.19%) ⬆️
test-optimization-playwright-playwright-reporting 60.86% <ø> (-0.07%) ⬇️
test-optimization-playwright-playwright-test-management 60.32% <ø> (-0.11%) ⬇️
test-optimization-playwright-playwright-test-span 59.57% <ø> (-0.08%) ⬇️
test-optimization-selenium 58.77% <ø> (-0.16%) ⬇️
test-optimization-testopt 57.44% <ø> (+0.07%) ⬆️
test-optimization-vitest 72.70% <ø> (+0.02%) ⬆️
test-optimization-vitest-browser 58.62% <ø> (-0.02%) ⬇️
test-optimization-webdriverio 64.91% <ø> (+0.04%) ⬆️

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.

@BridgeAR
BridgeAR marked this pull request as ready for review August 14, 2026 20:28
@BridgeAR
BridgeAR requested a review from a team as a code owner August 14, 2026 20:28
@BridgeAR
BridgeAR requested review from wconti27 and removed request for a team August 14, 2026 20:28
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.

1 participant