Skip to content

docs(runtimes): Cloudflare Workers AI tracing (TH-8278) - #964

Draft
nik13 wants to merge 7 commits into
mainfrom
feat/th-8278-cloudflare-workers-ai
Draft

nik13 wants to merge 7 commits into
mainfrom
feat/th-8278-cloudflare-workers-ai

Conversation

@nik13

@nik13 nik13 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes TH-8278 (parent TH-8103).

Replace the copied workerd tracing/exporter implementation with the published @traceai/[email protected] package. The guide now uses ordinary Node.js global fetch calls to Workers AI's OpenAI-compatible /ai/v1/chat/completions endpoint, with one startup preload and no tracing imports in the application.

  • Remove the custom exporter, REST-to-binding adapter, Wrangler configurations, stand-in handler and internal verification diary from the customer setup.
  • Preserve the existing page URL and update the integration catalog to describe the actual Node REST path.
  • Document content capture defaults, privacy flags, response consumption and natural-exit flushing.
  • Add a small executable application, pinned published dependency, five offline conformance tests and a GitHub Actions Node 20.6.0 / 22.18.0 matrix.
  • Merge current main (ddca13930bd9c4b9cc80384b7cf2b1a0d71fa43d) and resolve the integration-catalog conflict without dropping other integrations.

Why this path

The old recipe transferred maintenance of tracing source to customers. The released preload recognizes Cloudflare's host and the OpenAI-compatible chat protocol. It is a maintained path for an existing Node REST client and does not require a Worker deployment or Cloudflare account-setting changes.

Cloudflare Workers native OTLP destinations and AI Gateway OTLP export are separate supported Cloudflare mechanisms; this PR no longer labels native export unsupported. It does not configure either service or claim that the Node preload instruments deployed Workers, env.AI.run, streaming, tools, or Worker lifecycle spans.

Verification

All execution was in E2B or GitHub Actions, not on the local machine.

  • E2B th8103-cf964-node20-r1: Node 20.6.0, published @traceai/auto 0.1.2 / @traceai/fi-core 1.2.3; 5/5 passed. Verifies one model span (no duplicate), provider/model/usage/project routing, input/output hiding, HTTP 403 ERROR export with a nonzero application exit, missing provider credentials, and exact MDX/application parity. Captured OTLP excludes synthetic credentials and the account ID. This is a fake provider transport plus real package/exporter/loopback collector, not a live Cloudflare call. Sandbox termination confirmed.
  • E2B th8103-cf964-offline-r1: 5/5 example tests; 273/273 docs integration tests; integration TypeScript check passed; zero broken navigation or content links. The full Astro build then hit Node's approximately 2 GiB heap limit (exit 134). Sandbox termination confirmed.
  • E2B th8103-cf964-build-r2: full Astro build and Pagefind passed with NODE_OPTIONS=--max-old-space-size=6144; the Workers AI page rendered, and Pagefind indexed 851 pages. Exit 0; sandbox termination confirmed. This resolves the first run's heap-limit failure without a repository build-configuration change.
  • Re-run the committed conformance test from examples/runtimes/cloudflare-workers-ai with npm ci --ignore-scripts --no-audit --no-fund && npm test. No provider credentials or external model calls are required by these tests.
  • GitHub checks on head c12c294b46d26637a7dc93ed7667db41abd59cbd: 10/10 successful, including PR Checks (docs build/Pagefind, browser checks, link audit and Helicone conformance), Workers AI Node 20.6.0 / 22.18.0 conformance, Temporal Go contracts and FastMCP contracts.

Publication blocker — keep draft

The approved credential-staging helper failed before starting a provider sandbox: missing in key file: ['CLOUDFLARE_API_TOKEN']. No real Cloudflare calls were made and no trace was forwarded to Future AGI Cloud for this replacement. Historical workerd evidence does not qualify the new package route.

Required human step: make a Workers AI Read token for the intended account available to the existing approved staging helper, without sharing it in the PR or chat. Then run 2–3 minimal calls with the documented Llama 3.2 1B model, check captured OTLP for provider-key absence, forward one real trace to the th8103-docs Cloud project and record its trace ID. No Worker deployment or account-setting change is needed.

Do not merge, publish or close TH-8278 until that live qualification succeeds and the latest-head checks are green. No ticket was closed and no merge/publication was performed in this pass.

Review scope

Reviewed against the internal minimal-code, failure-mode, PR, naming and testing standards. The actual diff is confined to this guide/catalog entry, replacement example and its CI. There are no migrations, API/EE boundaries or frontend contracts changed. Product E2E coverage is not applicable (no e2e/ harness). The new tests and docs gates provide offline evidence only; missing live provider/Cloud qualification remains the release blocker. No separate review comment or approval was posted.

🤖 Generated with Claude Code

In-isolate OpenTelemetry recipe around env.AI.run with awaited flush, example Worker, unit tests and a local workerd E2E script. Native Cloudflare OTLP export documented as unsupported.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
nik13 and others added 2 commits October 19, 2026 17:23
Run the recipe against the real Workers AI API (llama-3.1-8b-instruct): success with real usage, real 400 error, privacy scan. Adds the live-entry REST-backed env.AI used for the run and a note on the 2s flush bound against a slow collector.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…H-8278)

The warning still said no Cloudflare API was called and no real model responses
were exercised, which the 2026-10-19 section contradicts. It now says the calls went
to the real Workers AI API, not through the ai binding, nothing was deployed, and the
e2e script still uses a stand-in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nik13
nik13 marked this pull request as ready for review October 21, 2026 22:46
Preserve current integration catalog entries alongside the Workers AI guide.

Co-Authored-By: Claude Code <[email protected]>
@nik13
nik13 marked this pull request as draft November 9, 2026 01:27
Use published @traceai/auto 0.1.2 on the OpenAI-compatible REST endpoint. Add offline conformance for span metadata, content privacy, HTTP failure and snippet parity. Keep live qualification blocked on the missing staged Cloudflare token.

Co-Authored-By: Claude Code <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant