Skip to content

fix(test-optimization): bound payload delivery lifecycle - #10044

Draft
juan-fernandez wants to merge 12 commits into
masterfrom
juan-fernandez/test-optimization-delivery-lifecycle
Draft

fix(test-optimization): bound payload delivery lifecycle#10044
juan-fernandez wants to merge 12 commits into
masterfrom
juan-fernandez/test-optimization-delivery-lifecycle

Conversation

@juan-fernandez

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

Copy link
Copy Markdown
Collaborator

What does this PR do?

Makes Test Optimization payload delivery more reliable when tests produce data faster than the intake can receive it.

  • Keeps pending payloads in a bounded 64 MiB queue instead of dropping them as soon as the transport is busy.
  • Retries temporary HTTP, network, and request-timeout failures.
  • Gives each request attempt its own timeout while keeping the existing 60-second hard limit for the final flush. The final flush is the tracer's last attempt to send data before the test process exits.
  • Reports a more specific error_type and HTTP status_code when delivery fails.

Only Test Optimization opts into retaining payloads while the transport is busy. Other products keep their existing behavior.

Motivation

Large test runs can finish many tests at once and create a short burst of payloads. Previously, a full transport buffer or one slow request could cause data loss during this burst.

This PR gives temporary failures time to recover without waiting forever or allowing memory use to grow forever. Payloads can still be dropped after the 64 MiB queue limit or the 60-second final-flush limit is reached.

Additional Notes

This work was extracted from #9987 and includes the changes previously split into #10045. It builds on the concurrency, HTTP retry, and final-flush timeout changes from #10038, #10039, and #10040.

Verified with focused request, exporter, writer, telemetry, and final-flush tests, plus repeated web-ui end-to-end runs.

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

ℹ️ 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/dd-trace/src/ci-visibility/exporters/request.js Outdated
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/test-optimization-delivery-lifecycle branch from c336b20 to e3736d0 Compare August 28, 2026 11:46
@dd-octo-sts

dd-octo-sts Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.65 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

@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review
/datadog autotest review

@datadog-prod-us1-4

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

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 1 test - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
Patch Coverage: 99.63%
Overall Coverage: 98.49% (-0.15%)

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

@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 Agent fallback path still discards Test Optimization payloads during exporter backpressure. Readable request bodies also bypass the 64 MiB queue limit while the request layer buffers them.

Open Bits AI session

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

Comment thread packages/dd-trace/src/exporters/common/writer.js
Comment thread packages/dd-trace/src/ci-visibility/exporters/request.js Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: e3736d09f5

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

@pr-commenter

pr-commenter Bot commented Aug 28, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-01 15:59:09

Comparing candidate commit aba4765 in PR branch juan-fernandez/test-optimization-delivery-lifecycle with baseline commit ae57e03 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2296 metrics, 14 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 [-29467.702KB; +28933.157KB] or [-16.271%; +15.976%]

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

  • unstable max_rss_usage [-9.712MB; +13.355MB] or [-4.220%; +5.802%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-24

  • unstable max_rss_usage [-16.359MB; +35.156MB] or [-4.893%; +10.515%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-26

  • unstable max_rss_usage [-36.439MB; +60.605MB] or [-12.761%; +21.224%]

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

  • unstable max_rss_usage [-28.285MB; +15.514MB] or [-7.343%; +4.027%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-302.163ms; +397.285ms] or [-6.146%; +8.081%]
  • unstable execution_time [-302.427ms; +397.322ms] or [-6.051%; +7.950%]
  • unstable throughput [-132048.157op/s; +100548.294op/s] or [-7.862%; +5.987%]

scenario:llmobs-encode-unicode-mixed-20

  • unstable max_rss_usage [-8.823MB; +5.685MB] or [-10.856%; +6.995%]

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

  • unstable max_rss_usage [-8104.237KB; +6546.637KB] or [-5.730%; +4.629%]

scenario:plugin-pg-service-26

  • unstable cpu_usage_percentage [-6.194%; +6.038%]
  • unstable execution_time [-66.111ms; +76.046ms] or [-7.178%; +8.257%]
  • unstable throughput [-436599.631op/s; +378515.867op/s] or [-6.600%; +5.722%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-2.559MB; +11.404MB] or [-3.075%; +13.707%]

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.63370% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.48%. Comparing base (ae57e03) to head (aba4765).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...es/dd-trace/src/ci-visibility/exporters/request.js 99.38% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10044      +/-   ##
==========================================
- Coverage   98.63%   98.48%   -0.15%     
==========================================
  Files         996      997       +1     
  Lines      152198   152501     +303     
  Branches    12857    12830      -27     
==========================================
+ Hits       150116   150191      +75     
- Misses       2082     2310     +228     
Flag Coverage Δ
aiguard 63.15% <64.00%> (-0.04%) ⬇️
aiguard-integration 58.95% <60.00%> (-0.01%) ⬇️
apm-bucket-0 62.49% <64.00%> (-0.04%) ⬇️
apm-bucket-1 67.93% <64.00%> (-0.04%) ⬇️
apm-bucket-2 62.61% <64.00%> (-4.91%) ⬇️
apm-bucket-3 64.34% <64.00%> (-0.04%) ⬇️
apm-capabilities-tracing 62.60% <99.63%> (+0.09%) ⬆️
apm-integrations-aerospike 60.50% <64.00%> (-0.04%) ⬇️
apm-integrations-confluentinc-kafka-javascript 66.58% <64.00%> (-0.04%) ⬇️
apm-integrations-couchbase 61.02% <64.00%> (-0.03%) ⬇️
apm-integrations-http 66.27% <64.00%> (+0.04%) ⬆️
apm-integrations-kafkajs 67.19% <64.00%> (-0.04%) ⬇️
apm-integrations-next 63.83% <64.00%> (-0.04%) ⬇️
apm-integrations-prisma ?
appsec 76.76% <100.00%> (+0.02%) ⬆️
appsec-express_fastify_graphql 72.70% <64.00%> (+0.02%) ⬆️
appsec-integration 49.56% <47.22%> (+0.04%) ⬆️
appsec-kafka_ldapjs_lodash 67.40% <64.00%> (-0.03%) ⬇️
appsec-mongodb-core_mongoose_mysql 70.65% <64.00%> (+0.02%) ⬆️
appsec-next 57.16% <47.22%> (+0.04%) ⬆️
appsec-node-serialize_passport_postgres 70.12% <64.00%> (+0.02%) ⬆️
appsec-sourcing_stripe_template 68.55% <64.00%> (+0.03%) ⬆️
debugger 69.08% <92.00%> (-0.02%) ⬇️
instrumentations-bucket-0 56.06% <52.00%> (-0.03%) ⬇️
instrumentations-bucket-1 64.15% <64.00%> (-0.04%) ⬇️
instrumentations-bucket-10 53.28% <37.14%> (-0.03%) ⬇️
instrumentations-bucket-11 65.67% <64.00%> (+0.04%) ⬆️
instrumentations-bucket-12 61.38% <64.00%> (-0.04%) ⬇️
instrumentations-bucket-13 56.26% <52.00%> (-0.03%) ⬇️
instrumentations-bucket-14 55.71% <52.00%> (-0.03%) ⬇️
instrumentations-bucket-2 56.92% <52.00%> (-0.03%) ⬇️
instrumentations-bucket-3 57.17% <52.00%> (-0.03%) ⬇️
instrumentations-bucket-4 63.77% <64.00%> (-0.04%) ⬇️
instrumentations-bucket-5 56.52% <52.00%> (-0.03%) ⬇️
instrumentations-bucket-6 58.12% <45.71%> (-0.03%) ⬇️
instrumentations-bucket-7 65.64% <64.00%> (-0.04%) ⬇️
instrumentations-bucket-8 62.91% <64.00%> (-0.03%) ⬇️
instrumentations-bucket-9 64.50% <64.00%> (-0.04%) ⬇️
instrumentations-instrumentation-couchbase 54.68% <52.00%> (-0.03%) ⬇️
instrumentations-instrumentation-zlib 55.75% <52.00%> (-0.03%) ⬇️
instrumentations-integration-esbuild 34.52% <3.84%> (-0.01%) ⬇️
llmobs-ai_anthropic_bedrock 66.70% <64.00%> (-0.03%) ⬇️
llmobs-bucket-1 64.83% <64.00%> (-0.03%) ⬇️
llmobs-openai 66.68% <64.00%> (-0.03%) ⬇️
llmobs-openai-agents_vertex-ai 63.97% <64.00%> (-0.03%) ⬇️
llmobs-sdk 75.88% <64.00%> (-0.04%) ⬇️
master-coverage 98.48% <99.63%> (?)
openfeature 59.57% <60.00%> (-0.01%) ⬇️
openfeature-unit 58.26% <52.00%> (-0.03%) ⬇️
platform-core_esbuild_instrumentations-misc 41.09% <38.88%> (-0.02%) ⬇️
platform-integration 64.79% <64.00%> (-0.01%) ⬇️
platform-shimmer_unit-guardrails_webpack 38.93% <38.88%> (-0.02%) ⬇️
plugins-browser-bunyan_bullmq_cassandra 66.22% <64.00%> (-0.04%) ⬇️
plugins-bucket-0 60.90% <64.00%> (-0.03%) ⬇️
plugins-bucket-1 58.12% <60.00%> (-0.01%) ⬇️
plugins-bucket-11 67.66% <64.00%> (-0.03%) ⬇️
plugins-bucket-18 65.93% <64.00%> (+0.47%) ⬆️
plugins-bucket-19 68.37% <64.00%> (+3.41%) ⬆️
plugins-bucket-20 69.11% <64.00%> (+0.45%) ⬆️
plugins-bucket-4 61.06% <64.00%> (-0.04%) ⬇️
plugins-cookie_cookie-parser_crypto 55.66% <52.00%> (-0.03%) ⬇️
plugins-fastify_fetch_fs 65.32% <64.00%> (-0.04%) ⬇️
plugins-generic-pool_google-cloud-pubsub_grpc 68.92% <64.00%> (-0.04%) ⬇️
plugins-handlebars_hapi_hono 63.58% <64.00%> (-0.04%) ⬇️
plugins-ioredis_knex_langgraph 61.59% <64.00%> (-0.04%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 63.31% <64.00%> (-0.03%) ⬇️
plugins-lodash_mariadb_memcached 63.69% <64.00%> (-0.13%) ⬇️
plugins-moleculer_mongodb_mongodb-core 66.03% <64.00%> (-0.04%) ⬇️
plugins-mongoose_multer_mysql 63.89% <64.00%> (-0.04%) ⬇️
plugins-mysql2_nats_node-serialize 66.10% <64.00%> (-0.04%) ⬇️
plugins-opensearch_passport-http_pino 63.99% <64.00%> (-0.04%) ⬇️
plugins-postgres_process_pug 63.03% <64.00%> (-0.04%) ⬇️
plugins-redis_router_sequelize 66.60% <64.00%> (-0.04%) ⬇️
plugins-test-and-upstream-rhea_undici_url ?
plugins-undici_url_valkey 62.44% <64.00%> (?)
plugins-valkey_vm_winston ?
plugins-vm_winston_ws 64.71% <64.00%> (?)
plugins-ws ?
profiling 66.19% <64.00%> (-0.04%) ⬇️
serverless-aws-sdk-aws-sdk 55.41% <45.71%> (-0.03%) ⬇️
serverless-aws-sdk-base-inject-field 55.23% <52.00%> (-0.03%) ⬇️
serverless-aws-sdk-bedrockruntime 58.66% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-client 60.02% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-dynamodb 59.09% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-eventbridge 57.61% <45.71%> (-0.03%) ⬇️
serverless-aws-sdk-kinesis 63.07% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-lambda 61.03% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-s3 59.15% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-serverless-peer-service 63.64% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-sns 63.95% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-sqs 64.42% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-stepfunctions 59.00% <64.00%> (-0.03%) ⬇️
serverless-aws-sdk-util 55.85% <52.00%> (-0.03%) ⬇️
serverless-bucket-0 57.76% <60.00%> (-0.01%) ⬇️
serverless-bucket-1 63.66% <64.00%> (-0.04%) ⬇️
test-optimization-cucumber 70.54% <77.65%> (+0.01%) ⬆️
test-optimization-cypress 64.74% <61.17%> (+0.03%) ⬆️
test-optimization-jest 72.25% <89.01%> (+0.17%) ⬆️
test-optimization-mocha 72.00% <77.65%> (+0.05%) ⬆️
test-optimization-playwright-playwright-atr 59.61% <53.11%> (-0.27%) ⬇️
test-optimization-playwright-playwright-efd 60.41% <50.96%> (-0.09%) ⬇️
test-optimization-playwright-playwright-final-status 60.02% <48.64%> (-0.09%) ⬇️
test-optimization-playwright-playwright-impacted-tests 60.14% <48.64%> (+0.04%) ⬆️
test-optimization-playwright-playwright-reporting 61.16% <61.53%> (-0.05%) ⬇️
test-optimization-playwright-playwright-test-management 61.19% <50.96%> (-0.10%) ⬇️
test-optimization-playwright-playwright-test-span 59.89% <53.11%> (+<0.01%) ⬆️
test-optimization-selenium 58.87% <52.01%> (-0.10%) ⬇️
test-optimization-testopt 61.83% <65.93%> (+0.09%) ⬆️
test-optimization-vitest 72.66% <65.56%> (-0.01%) ⬇️
test-optimization-vitest-browser 58.68% <48.64%> (-0.08%) ⬇️
test-optimization-webdriverio 65.48% <53.84%> (-0.01%) ⬇️

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.

@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: 9357c29e5f

ℹ️ 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/dd-trace/src/ci-visibility/exporters/request.js Outdated
Comment thread packages/dd-trace/src/exporters/common/writer.js
Comment thread packages/dd-trace/src/ci-visibility/exporters/request.js

@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: 2862369d20

ℹ️ 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/dd-trace/src/ci-visibility/exporters/request.js Outdated
Comment thread packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js Outdated
Comment thread packages/dd-trace/src/ci-visibility/encode/json-encoder.js Outdated
A 1,000-log batch benchmark improved from 91-93 ms to 57-60 ms across two fresh runs (about 37% faster).

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

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

retryTimer = setTimeout(attempt, Math.min(50, remaining), attemptIndex)
if (!commonRequest.writable) {
waitingForBackpressure = true
retryTimer = setTimeout(attempt, Math.min(BACKPRESSURE_RETRY_MS, remaining), attemptIndex)

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 Bound concurrent backpressure polling timers

When flushInterval === 0, BufferingExporter._export starts a request for every append, and a saturated common transport makes each retained request create and repeatedly reschedule its own 50 ms timer here. The byte cap does not bound request count or timer/closure overhead, so a burst of small traces or logs can accumulate tens of thousands of polling timers and cause a CPU/memory spike while the transport remains blocked; cap queued request count or use a shared backpressure waiter.

AGENTS.md reference: AGENTS.md:L194-L200

Useful? React with 👍 / 👎.

@juan-fernandez
juan-fernandez marked this pull request as draft August 28, 2026 14:18
Cap screenshot retries even during finalization, let ready Test Optimization responses beat creation-time timeouts, keep owned agent-discovery retries alive, stabilize Playwright dynamic-name fixtures, and isolate nested integration runs from incomplete GitHub Actions metadata.
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