Skip to content

test(core): add Cloudflare Workers (workerd) acceptance test - #9442

Closed
bm1549 wants to merge 2 commits into
brian.marks/cf-als-loadfrom
brian.marks/cf-wrangler-ci
Closed

test(core): add Cloudflare Workers (workerd) acceptance test#9442
bm1549 wants to merge 2 commits into
brian.marks/cf-als-loadfrom
brian.marks/cf-wrangler-ci

Conversation

@bm1549

@bm1549 bm1549 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Final PR in the Cloudflare Workers stack. Adds an acceptance test proving dd-trace-js loads, initializes, and emits a span over OTLP inside the real Workers runtime (workerd), plus a CI job that runs it:

  • Worker fixture (integration-tests/cloudflare-workers/): imports the local dd-trace build, calls tracer.init() inside the fetch handler (workerd forbids init at module scope), emits a flat span, and holds the isolate with ctx.waitUntil until the OTLP request leaves.
  • Test: boots the fixture in real workerd via wrangler's unstable_dev, points OTLP at a mock receiver (reusing FakeAgent's /v1/traces route), and asserts the receiver actually captured a span named cf.worker.test with service cf-workers-ci — not merely that the worker returned HTTP 200 (which a silently no-op'd tracer would also do).
  • CI: .github/workflows/cloudflare-workers.yml (Node 22), modeled on electron.yml; adds wrangler as a devDependency.

This passes only because the stack's fixes (#9437, #9440, #9441) let dd-trace load in workerd — it is the acceptance gate for that work.

Motivation

Locks in Cloudflare Workers support with a real-runtime regression test (#1892) so future changes can't silently re-break module-load in workerd.

Additional Notes

  • Stacked on fix(core): tolerate partial AsyncLocalStorage at load for restricted runtimes #9441. No dd-trace production source is changed — test + CI only.
  • The fixture pins compatibility_date: 2026-07-18 because FinalizationRegistry/WeakRef are gated by compat date in workerd (absent at the nodejs_compat minimum 2024-09-23).
  • Follow-ups (separate PRs, not required for this gate): a promise-returning tracer.flush() to replace the fixed ctx.waitUntil delay with completion-driven flushing; and an optional FinalizationRegistry guard in opentracing/span.js so dd-trace also loads under older Workers compat dates.

Adds a fixture Worker plus an automated test that boots real workerd via
wrangler's unstable_dev, requires dd-trace via a relative import to this
repo's build, calls tracer.init() inside fetch(), emits a flat span, and
asserts the existing FakeAgent's /v1/traces route actually receives the
OTLP payload (an HTTP 200 from the Worker alone doesn't prove the span
left the isolate). This is the acceptance test for PRs #1-3, which fixed
the module-load gaps that let dd-trace load under workerd at all.

Also adds a dedicated CI job to run it, and pins wrangler as a
devDependency so CI has the CLI/unstable_dev API available.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bm1549 bm1549 added semver-patch AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos labels Jul 20, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.81 MB
Deduped: 7.47 MB
No deduping: 7.47 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 438.86 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-3

datadog-prod-us1-3 Bot commented Jul 20, 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.34% (+0.00%)

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

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.34%. Comparing base (8fa5ef6) to head (7fc73ff).

Additional details and impacted files
@@                   Coverage Diff                    @@
##           brian.marks/cf-als-load    #9442   +/-   ##
========================================================
  Coverage                    98.34%   98.34%           
========================================================
  Files                          925      925           
  Lines                       123177   123177           
  Branches                     10589    10687   +98     
========================================================
+ Hits                        121143   121144    +1     
+ Misses                        2034     2033    -1     
Flag Coverage Δ
aiguard 58.17% <ø> (ø)
aiguard-integration 57.04% <ø> (ø)
apm-bucket-0 58.43% <ø> (ø)
apm-bucket-1 64.53% <ø> (ø)
apm-bucket-2 63.59% <ø> (ø)
apm-bucket-3 60.88% <ø> (ø)
apm-capabilities-tracing 62.36% <ø> (ø)
apm-integrations-aerospike 57.56% <ø> (ø)
apm-integrations-confluentinc-kafka-javascript 62.47% <ø> (ø)
apm-integrations-couchbase 57.84% <ø> (+<0.01%) ⬆️
apm-integrations-http 63.58% <ø> (ø)
apm-integrations-kafkajs 63.03% <ø> (ø)
apm-integrations-next 59.97% <ø> (ø)
apm-integrations-prisma 59.40% <ø> (ø)
appsec 73.88% <ø> (ø)
appsec-express_fastify_graphql 71.47% <ø> (ø)
appsec-integration 51.89% <ø> (ø)
appsec-kafka_ldapjs_lodash 64.77% <ø> (ø)
appsec-mongodb-core_mongoose_mysql 68.49% <ø> (ø)
appsec-next 58.14% <ø> (ø)
appsec-node-serialize_passport_postgres 68.22% <ø> (+0.03%) ⬆️
appsec-sourcing_stripe_template 66.49% <ø> (ø)
debugger 65.84% <ø> (+0.01%) ⬆️
instrumentations-bucket-0 52.28% <ø> (ø)
instrumentations-bucket-1 61.07% <ø> (ø)
instrumentations-bucket-10 62.93% <ø> (ø)
instrumentations-bucket-11 52.29% <ø> (ø)
instrumentations-bucket-12 52.74% <ø> (ø)
instrumentations-bucket-13 52.24% <ø> (ø)
instrumentations-bucket-2 54.22% <ø> (ø)
instrumentations-bucket-3 60.03% <ø> (ø)
instrumentations-bucket-4 52.87% <ø> (ø)
instrumentations-bucket-5 58.27% <ø> (ø)
instrumentations-bucket-6 61.62% <ø> (ø)
instrumentations-bucket-7 59.17% <ø> (ø)
instrumentations-bucket-8 60.44% <ø> (ø)
instrumentations-bucket-9 62.30% <ø> (ø)
instrumentations-instrumentation-couchbase 51.53% <ø> (ø)
instrumentations-integration-esbuild 33.99% <ø> (ø)
llmobs-ai_anthropic_bedrock 63.27% <ø> (ø)
llmobs-bucket-1 62.57% <ø> (ø)
llmobs-openai 63.24% <ø> (ø)
llmobs-sdk 65.43% <ø> (ø)
llmobs-vertex-ai 59.92% <ø> (ø)
openfeature 54.65% <ø> (+0.08%) ⬆️
openfeature-unit 53.32% <ø> (ø)
platform-core_esbuild_instrumentations-misc 40.00% <ø> (ø)
platform-integration 62.24% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 39.29% <ø> (ø)
plugins-bucket-0 57.71% <ø> (ø)
plugins-bucket-1 55.13% <ø> (ø)
plugins-bucket-11 63.04% <ø> (ø)
plugins-bucket-18 62.85% <ø> (ø)
plugins-bucket-19 60.98% <ø> (ø)
plugins-bucket-20 62.84% <ø> (ø)
plugins-bucket-4 59.34% <ø> (ø)
plugins-bullmq_cassandra_cookie 62.62% <ø> (ø)
plugins-cookie-parser_crypto_dd-trace-api 57.51% <ø> (ø)
plugins-fetch_fs_generic-pool 59.62% <ø> (ø)
plugins-google-cloud-pubsub_grpc_handlebars 65.61% <ø> (ø)
plugins-hapi_hono_ioredis 61.05% <ø> (ø)
plugins-jest_knex_langgraph 56.32% <ø> (ø)
plugins-ldapjs_light-my-request_limitd-client 59.29% <ø> (-0.02%) ⬇️
plugins-lodash_mariadb_memcached 58.79% <ø> (ø)
plugins-moleculer_mongodb_mongodb-core 62.78% <ø> (ø)
plugins-mongoose_multer_mysql 59.88% <ø> (ø)
plugins-mysql2_nats_node-serialize 61.66% <ø> (ø)
plugins-opensearch_passport-http_pino 60.44% <ø> (ø)
plugins-postgres_process_pug 59.08% <ø> (ø)
plugins-redis_router_sequelize 62.92% <ø> (ø)
plugins-test-and-upstream-rhea_undici_url 62.51% <ø> (+0.03%) ⬆️
plugins-valkey_vm_winston 58.78% <ø> (ø)
plugins-ws 60.41% <ø> (ø)
profiling 63.03% <ø> (ø)
serverless-aws-sdk-aws-sdk 55.67% <ø> (ø)
serverless-aws-sdk-bedrockruntime 55.39% <ø> (ø)
serverless-aws-sdk-client 57.12% <ø> (ø)
serverless-aws-sdk-dynamodb 56.33% <ø> (+<0.01%) ⬆️
serverless-aws-sdk-eventbridge 49.83% <ø> (ø)
serverless-aws-sdk-kinesis 60.10% <ø> (ø)
serverless-aws-sdk-lambda 58.09% <ø> (ø)
serverless-aws-sdk-s3 56.26% <ø> (ø)
serverless-aws-sdk-serverless-peer-service 60.52% <ø> (ø)
serverless-aws-sdk-sns 60.91% <ø> (ø)
serverless-aws-sdk-sqs 61.35% <ø> (ø)
serverless-aws-sdk-stepfunctions 56.24% <ø> (ø)
serverless-aws-sdk-util 51.93% <ø> (ø)
serverless-bucket-0 55.17% <ø> (+<0.01%) ⬆️
serverless-bucket-1 60.04% <ø> (ø)
test-optimization-cucumber 72.94% <ø> (-0.06%) ⬇️
test-optimization-cypress 66.37% <ø> (+0.06%) ⬆️
test-optimization-jest 74.34% <ø> (-0.05%) ⬇️
test-optimization-mocha 74.67% <ø> (ø)
test-optimization-playwright-playwright-atr 61.38% <ø> (ø)
test-optimization-playwright-playwright-efd 61.58% <ø> (ø)
test-optimization-playwright-playwright-final-status 61.54% <ø> (ø)
test-optimization-playwright-playwright-impacted-tests 61.26% <ø> (ø)
test-optimization-playwright-playwright-reporting 61.16% <ø> (ø)
test-optimization-playwright-playwright-test-management 62.11% <ø> (ø)
test-optimization-playwright-playwright-test-span 61.24% <ø> (+0.01%) ⬆️
test-optimization-selenium 60.67% <ø> (ø)
test-optimization-testopt 59.18% <ø> (ø)
test-optimization-vitest 71.29% <ø> (ø)

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.

@pr-commenter

pr-commenter Bot commented Jul 20, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-20 20:03:15

Comparing candidate commit 7fc73ff in PR branch brian.marks/cf-wrangler-ci with baseline commit 8fa5ef6 in branch brian.marks/cf-als-load.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2312 metrics, 46 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-24

  • unstable execution_time [-210.178ms; +207.103ms] or [-7.926%; +7.810%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-230.476ms; +243.505ms] or [-9.001%; +9.510%]

scenario:appsec-appsec-enabled-with-attacks-24

  • unstable execution_time [-159902.008µs; +161207.841µs] or [-5.178%; +5.220%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-191.425ms; +185.008ms] or [-6.567%; +6.347%]

scenario:appsec-control-20

  • unstable execution_time [-127.706ms; +112.671ms] or [-7.763%; +6.849%]

scenario:appsec-control-24

  • unstable execution_time [-114.331ms; +111.726ms] or [-9.203%; +8.993%]

scenario:appsec-control-26

  • unstable execution_time [-119.738ms; +135.073ms] or [-9.733%; +10.979%]

scenario:appsec-iast-no-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-8.476ms; +17.357ms] or [-3.363%; +6.886%]

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

  • unstable execution_time [-21989.653µs; +22092.786µs] or [-8.639%; +8.679%]

scenario:appsec-iast-with-vulnerability-control-20

  • unstable execution_time [-27.100ms; +32.895ms] or [-4.937%; +5.992%]

scenario:appsec-iast-with-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-28.135ms; +35.542ms] or [-5.068%; +6.402%]

scenario:child_process-file-args-24

  • unstable execution_time [-26.337ms; +34.041ms] or [-5.528%; +7.145%]
  • unstable throughput [-131413.451op/s; +99222.730op/s] or [-5.990%; +4.523%]

scenario:child_process-shell-string-24

  • unstable execution_time [-9.198ms; +29.217ms] or [-2.872%; +9.124%]

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

  • unstable cpu_user_time [-1698.370ms; +577.335ms] or [-20.496%; +6.967%]
  • unstable execution_time [-1709.306ms; +577.587ms] or [-19.024%; +6.428%]
  • unstable instructions [-14.6G instructions; +4.8G instructions] or [-21.599%; +7.156%]
  • unstable throughput [-159.728op/s; +458.384op/s] or [-4.361%; +12.515%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable cpu_user_time [-2595.955ms; +4143.652ms] or [-27.163%; +43.357%]
  • unstable execution_time [-2600.450ms; +4159.214ms] or [-25.220%; +40.338%]
  • unstable instructions [-23.1G instructions; +36.9G instructions] or [-29.015%; +46.365%]
  • unstable max_rss_usage [-9.064MB; +12.727MB] or [-5.677%; +7.970%]
  • unstable throughput [-813.291op/s; +506.343op/s] or [-25.309%; +15.757%]

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

  • unstable cpu_user_time [-1770.754ms; +578.797ms] or [-21.362%; +6.983%]
  • unstable execution_time [-1791.667ms; +592.718ms] or [-19.904%; +6.585%]
  • unstable instructions [-15.0G instructions; +4.9G instructions] or [-22.140%; +7.307%]
  • unstable throughput [-160.660op/s; +474.373op/s] or [-4.386%; +12.951%]

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

  • unstable cpu_user_time [-3657.894ms; +3671.519ms] or [-35.528%; +35.660%]
  • unstable execution_time [-3712.269ms; +3701.186ms] or [-33.654%; +33.554%]
  • unstable instructions [-32280.2M instructions; +32312.8M instructions] or [-37.293%; +37.330%]
  • unstable max_rss_usage [-11561.026KB; +10713.026KB] or [-7.092%; +6.572%]
  • unstable throughput [-732.490op/s; +719.575op/s] or [-23.704%; +23.286%]

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

  • unstable cpu_user_time [-1703.264ms; +547.219ms] or [-20.620%; +6.625%]
  • unstable execution_time [-1741.846ms; +543.693ms] or [-19.390%; +6.052%]
  • unstable instructions [-14.6G instructions; +4.8G instructions] or [-21.695%; +7.091%]
  • unstable throughput [-146.109op/s; +474.510op/s] or [-3.988%; +12.952%]

scenario:dogstatsd-aggregated-20

  • unstable cpu_usage_percentage [-6.503%; +4.632%]
  • unstable execution_time [-87.815ms; +117.436ms] or [-6.791%; +9.082%]
  • unstable throughput [-765618.028op/s; +590178.215op/s] or [-6.527%; +5.032%]

scenario:dogstatsd-aggregated-26

  • unstable cpu_user_time [-42.376ms; +62.577ms] or [-4.245%; +6.269%]
  • unstable execution_time [-44.806ms; +63.378ms] or [-4.429%; +6.265%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-271.644ms; +345.193ms] or [-5.367%; +6.821%]
  • unstable execution_time [-272.059ms; +351.729ms] or [-5.301%; +6.853%]
  • unstable throughput [-127392.335op/s; +100548.926op/s] or [-7.796%; +6.153%]

scenario:plugin-mongodb-core-binary-hash-24

  • unstable execution_time [-127.758ms; +170.206ms] or [-4.429%; +5.900%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-4703.218KB; +5793.218KB] or [-5.929%; +7.303%]

The Cloudflare Workers acceptance test dir was unowned, failing
lint:codeowners:ci (--fail-on-unowned). Assign it to @DataDog/apm-idm-js,
matching the sibling runtime/bundler integration tests (electron, esbuild,
webpack).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos semver-patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant