test(core): add Cloudflare Workers (workerd) acceptance test - #9442
test(core): add Cloudflare Workers (workerd) acceptance test#9442bm1549 wants to merge 2 commits into
Conversation
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>
Overall package sizeSelf size: 6.81 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 |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7fc73ff | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-20 20:03:15 Comparing candidate commit 7fc73ff in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2312 metrics, 46 unstable metrics.
|
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>
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:integration-tests/cloudflare-workers/): imports the local dd-trace build, callstracer.init()inside thefetchhandler (workerd forbids init at module scope), emits a flat span, and holds the isolate withctx.waitUntiluntil the OTLP request leaves.workerdvia wrangler'sunstable_dev, points OTLP at a mock receiver (reusingFakeAgent's/v1/tracesroute), and asserts the receiver actually captured a span namedcf.worker.testwith servicecf-workers-ci— not merely that the worker returned HTTP 200 (which a silently no-op'd tracer would also do)..github/workflows/cloudflare-workers.yml(Node 22), modeled onelectron.yml; addswrangleras 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
compatibility_date: 2026-07-18becauseFinalizationRegistry/WeakRefare gated by compat date inworkerd(absent at thenodejs_compatminimum2024-09-23).tracer.flush()to replace the fixedctx.waitUntildelay with completion-driven flushing; and an optionalFinalizationRegistryguard inopentracing/span.jsso dd-trace also loads under older Workers compat dates.