Skip to content

feat(core): add shared request timing collector and middleware - #389

Open
ChristianPavilonis wants to merge 1 commit into
mainfrom
feat/shared-request-timing
Open

ChristianPavilonis wants to merge 1 commit into
mainfrom
feat/shared-request-timing

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Move generic request-timing ownership into EdgeZero: one portable origin, bounded phase slots, lifecycle marks, and application-owned payload under one shared mutex.
  • Add opt-in, insert-if-absent attachment middleware without moving application rendering or privacy policy upstream.
  • Coordinate adoption with Trusted Server #1121. TS migration and independent joint verification are complete against this exact candidate.

Changes

Crate / File Change
edgezero-core/src/request_timing.rs, src/lib.rs Generic RequestTimings<N, D>, consistent snapshots, compound updates, saturating accumulation, drop-time phase spans and explicit lifecycle marks
edgezero-core/src/middleware.rs Preserve an existing concrete handle; otherwise install request-local state unless the exact path is excluded
Core tests and shared adapter contract fixture Exercise typed application facade, one extension identity/origin, contention, invalid slots, poison recovery, cancellation, and portable runtime clock/attachment
Cloudflare/Fastly/Spin contract tests Run the shared timing scenario on each WASM runtime
Middleware guide and design/plan Document ownership, lifecycle limits, approved API contracts and coordinated delivery

Applications retain phase enums, domain facts, header names/order, serialization and exposure policy. In particular, Trusted Server retains Server-Timing rendering; no generic renderer is introduced. Callbacks run synchronously under one nonblocking mutex; panics propagate and poison recovery is best-effort, without rollback or payload validation. Attachment does not finalize requests, measure streamed-body completion, or cover unmatched routes.

Closes

No standalone EdgeZero issue. Related consumer work: IABTechLab/trusted-server#1121.

Test plan

Publication-stage reruns against this tree:

  • cargo test -p edgezero-core — 484 unit tests, two integration tests and one compile-fail doctest passed; 13 existing doctests ignored
  • cargo test --workspace --all-targets
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • cargo check --workspace --all-targets --features "fastly cloudflare spin"
  • cargo check -p edgezero-adapter-spin --target wasm32-wasip2 --features spin
  • git diff --check

Earlier implementation-stage validation, recorded in the committed plan (not rerun during publication):

  • WASM check/clippy matrix: Fastly wasm32-wasip1, Spin wasm32-wasip2, Cloudflare wasm32-unknown-unknown
  • Runtime contract suites: Cloudflare 8 tests in headless Chromium, Fastly 7 in Viceroy 0.17.0, Spin 13 in Wasmtime 44.0.1; Fastly library suite 88 tests
  • Generated-app build and excluded examples/app-demo gates
  • Docs lint/format and VitePress build
  • Deployed-provider smoke testing (local runtime harnesses are not deployed-provider evidence)
  • Trusted Server migration and joint validation at TS commit 2791ceb46908e6af04ccaae0c10b29d35336a9f4

Independent final verification

  • All 22 reported GitHub checks succeeded. Test/format CI used a synthetic merge whose tree was verified identical to candidate 9c03cc59300363ae5339fc970dded08ede563e98.
  • Fresh local core tests, documentation checks/build, and actual Cloudflare/Fastly/Spin WASM contract runs passed. The shared runtime test covers both middleware-created and preinstalled handles.
  • TS pins this exact commit without local overrides. All four TS adapter suites, CLI/parity, native/WASM lints, local integration/EC lifecycle, 899 Vitest tests, focused GPT diagnostics, and complete Next.js/WordPress browser suites passed.
  • Independent API/correctness/simplicity and joint consumer reviews found no remaining issues. The Axum regression demonstrates the original collector-reset failure and its fix. All 14 Trusted Server checks also passed at 2791ceb46908e6af04ccaae0c10b29d35336a9f4 before requesting review.

Coordinated delivery / merge gate

Trusted Server temporarily pins all six EdgeZero dependencies to 9c03cc59300363ae5339fc970dded08ede563e98 for integration and joint PR verification, with no local path override and one resolved EdgeZero core identity. That temporary commit pin is not the final delivery pin.

Trusted Server #1121 needs an actual approved EdgeZero release tag before merging to main. Replace all temporary pins with that release, regenerate and inspect its lockfile, and revalidate. Review readiness does not waive the release requirement. No merge or tag/release has been performed.

Checklist

  • Changes follow CLAUDE.md conventions
  • No Tokio or UUID dependencies added to core or adapter crates
  • Route params use {id} syntax where applicable; routing unchanged
  • Consumer types imported from edgezero_core, not directly from http
  • Store wiring unchanged (registry requirement not applicable)
  • New code has tests
  • No secrets or credentials committed
  • Independent EdgeZero reviews cleared

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.

2 participants