Skip to content

One http.server span per request: the worker defers to Effect's tracer#985

Merged
RhysSullivan merged 1 commit into
mainfrom
claude/dedupe-server-spans
Jun 12, 2026
Merged

One http.server span per request: the worker defers to Effect's tracer#985
RhysSullivan merged 1 commit into
mainfrom
claude/dedupe-server-spans

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

The bug

Every API/MCP request produced two identical sibling http.server spans: the worker-boundary span server.ts opens (scope executor-cloud-worker) and the one Effect's HttpMiddleware.tracer opens for app-owned paths (scope executor-cloud). Both join the caller's traceparent, so they land in the same trace as twins — the waterfall shows a childless duplicate next to the real envelope (all the workos/store/db children parent under Effect's span), and server-span ingest is doubled. In the production dataset that's ~25k duplicate spans against ~40k real ones on /mcp alone.

The duplicate was invisible until the browser span export landed (#981) and made joined traces inspectable end to end — the first real waterfall showed the twin immediately.

The fix

The worker now skips its envelope span for app-owned paths (app-paths.ts: /api/*, /mcp, /.well-known/*) — Effect's middleware already parses traceparent itself and parents the child spans there. Non-app paths (Start SSR, the marketing proxy, /_astro assets — which Effect never sees) keep the worker span, and the flush-on-waitUntil runs on both branches so batched exports survive the isolate.

After deploy, executor-cloud-worker-scope server spans become a meaningful signal ("non-app traffic") instead of noise.

Verified

Against the suite-owned motel trace store (#979): API + browser scenario runs record exactly one http.server span per trace (worker scope appears only on / and SSR routes), and the browser→server join is intact — executor-web client span → executor-cloud server span → workos/user_store/fumadb children. Cloud observability unit tests 10/10; lint/format/typecheck clean.

Every API/MCP request produced TWO identical sibling http.server spans:
the worker-boundary span server.ts opens (scope executor-cloud-worker)
AND the one Effect's HttpMiddleware.tracer opens for app-owned paths
(scope executor-cloud) — both joined the caller's traceparent, so the
waterfall showed a childless twin next to the real envelope, and server
span ingest was doubled (visible in Axiom: 39.7k executor-cloud vs
24.9k executor-cloud-worker spans on /mcp alone).

The worker now skips its span for app-owned paths (app-paths.ts: /api/*,
/mcp, /.well-known/*) — Effect's middleware already parses traceparent
and parents the workos/store/db children there. Non-app paths (Start
SSR, marketing proxy, /_astro assets) keep the worker envelope span,
and the flush-on-waitUntil still runs on both branches so batched
exports survive the isolate.

Verified against the suite motel: API scenario + browser scenario runs
now record exactly one http.server per trace (worker scope only on /
and SSR routes), browser→server join intact (executor-web client span
→ executor-cloud server span → workos/user_store/fumadb children);
cloud observability unit tests green.

Found via the prod Axiom dataset right after #981 made browser traces
land — the duplicate was previously invisible without the join.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 60a39bf Jun 12 2026, 06:33 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 60a39bf Commit Preview URL

Branch Preview URL
Jun 12 2026, 06:32 PM

@RhysSullivan RhysSullivan merged commit 51835e1 into main Jun 12, 2026
12 checks passed
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

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