feat(cloudflare): expose Worker observability as first-class arg#1
feat(cloudflare): expose Worker observability as first-class arg#1guidefari wants to merge 1 commit into
Conversation
Add an `observability` prop to `cloudflare.Worker` so users can enable Cloudflare's logs and traces without reaching for `transform.worker`. The same prop is exposed on the components that create Workers internally: `SsrSite` (Astro, ReactRouter, TanStackStart, SolidStart), `StaticSiteV2`, and `Workflow`. `Cron`, `Queue.subscribe`, and `Auth` already spread `WorkerArgs` and pick it up automatically. Normalization sets top-level `enabled: true` and defaults `logs.invocationLogs: true` whenever `logs` is provided, while still letting the user override any field. `destinations` and `persist` are deferred; the upstream `WorkersScriptObservability` shape lets us add them later without breaking changes. Implements docs/design/cloudflare-worker-observability.md.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds an optional ChangesCloudflare Worker observability support
Estimated code review effort: 2 (Simple) | ~10 minutes Related PRs: None specified. Suggested labels: enhancement, cloudflare Suggested reviewers: None specified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds an
observabilityprop tocloudflare.Workerso users can enable Cloudflare's logs and traces without reaching fortransform.worker. The same prop is exposed on every component that creates a Worker internally:cloudflare.Worker(root, with normalization)cloudflare.SsrSiteand subclasses (Astro,ReactRouter,TanStackStart,SolidStart) viaextends SsrSiteArgscloudflare.StaticSiteV2cloudflare.Workflowcloudflare.Cron,cloudflare.Queue.subscribe, andcloudflare.Authpick it up automatically throughWorkerArgs(no changes needed)API
Normalization
When
observabilityis provided, SST sets the top-levelenabled: trueand, forlogs, also defaultsinvocationLogs: true. User-providedheadSamplingRateand explicitenabled/invocationLogsvalues still win via the spread.destinationsandpersistare intentionally omitted; they can be added later without breaking changes.Out of scope
destinationsandpersist(deferred per design doc open question 2)observability: trueshorthand (deferred per design doc open question 1)pkg/server/resource/cloudflare-worker-script.gostill has the staleobservabilitystruct withHeapSamplingRate. Left as-is per design doc open question 3; theWorkercomponent uses@pulumi/cloudflare'scf.WorkersScriptand never calls the Go provider.Verification
bun run typecheckpasses (platform + sdk)bun run test(platform): 100/100 tests pass; the 3 failing test files are pre-existingERR_TRACE_EVENTS_UNAVAILABLEerrors from@pulumi/runtimeon this Node version, unrelated to this change (reproduce on the base commit)bun run test:cli(Go) not run locally —goisn't installed in this env. No Go files were touched.Implements
docs/design/cloudflare-worker-observability.md.Summary by cubic
Expose a first-class
observabilityoption to enable Cloudflare Worker logs and traces with simple config. This works across all components that create Workers.New Features
observabilitytocloudflare.Workerfor logs and traces (with optional head sampling rates).cloudflare.SsrSite(Astro, ReactRouter, TanStackStart, SolidStart),cloudflare.StaticSiteV2, andcloudflare.Workflow;cloudflare.Cron,cloudflare.Queue.subscribe, andcloudflare.Authinherit it automatically.Notes
enabled: true; for logs, defaultsinvocationLogs: true. User values override defaults.destinationsandpersistare not exposed yet.Written for commit 51cdd17. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes