Repository navigation
Closed
Labels
Description
Let's add some 1st class cloudflare workers support (finally)!
We've had https://github.com/robertcepa/toucan-js for a while that has worked great, but doesn't match our unified API and doesn't have full support for performance, cron monitoring, and more.
First we can start off by making a basic package, @sentry/cloudflare-workers
### Initial
- [ ] https://github.com/getsentry/sentry-javascript/issues/12685
- [ ] https://github.com/getsentry/sentry-javascript/pull/12953
- [ ] https://github.com/getsentry/sentry-javascript/pull/13025
- [ ] https://github.com/getsentry/sentry-javascript/pull/13087
- [ ] https://github.com/getsentry/sentry-javascript/pull/13096
### After First Release
- [ ] https://github.com/getsentry/sentry-javascript/issues/13111
- [ ] https://github.com/getsentry/platformicons/issues/173
- [ ] https://github.com/getsentry/sentry-release-registry/pull/164
- [ ] https://github.com/getsentry/sentry-javascript/pull/13206
- [ ] Add wizard command to setup cloudflare workers sdk
- [ ] Add cloudflare workers to sentry onboarding
- [ ] Ensure distributed tracing between cloudflare workers
- [ ] Publish docs for cloudflare workers package
- [ ] Add version metadata https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/
Once the SDK is in a good state we can think about better instrumentation for the different bindings that cloudflare workers exposes. Top of mind is:
### Bindings support
- [ ] https://github.com/getsentry/sentry-javascript/issues/13141
- [ ] Add cloudflare queues instrumentation https://developers.cloudflare.com/queues/configuration/javascript-apis/
- [ ] Add r2 instrumentation https://developers.cloudflare.com/r2/api/workers/workers-api-reference/
- [ ] Add kv instrumentation https://developers.cloudflare.com/kv/
- [ ] Add durable objects instrumentation
At the same time we should make sure that we add support for our metaframeworks to use the Cloudflare workers SDK
### Support metaframeworks
- [ ] https://github.com/getsentry/sentry-javascript/pull/13123
- [ ] https://github.com/getsentry/sentry-javascript/issues/5610
- [ ] https://github.com/getsentry/sentry-javascript/issues/8291
- [ ] https://github.com/getsentry/sentry-javascript/issues/11920
- [ ] Astro
- [ ] Nuxt
- [ ] SolidStart
- [ ] Next.js (https://github.com/getsentry/sentry-javascript/issues/11920)
Reacted by David De Sloovere, Peter Graugaard, David Dodlek, Christian A. Jacobsen, Brendan Irvine-Broque, Gerben Neven, Josh Spinney, Almana.cc, Zack Sarver, Luca Steeb and 21 more
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
AbhiPrasad commentedon Jun 24, 2024
Initial thinking of the general API.
We're probably only going to support
ES modulessyntax.Current toucan requires you to always instantiate
new Toucan. Ideally we can avoid this by exposing a helper that wrapsexport default objfrom the entry point.It would probably automatically try to read
env.SENTRY_DSNto get the sentry dsn.For further customization, you can take a function
withSentryHandlerthat isolates sentry to the specific handler you care about. This allows you to override how sentry is initialized for that specific handler withoutWith the
withSentryAPI's you'll need to havecompatibility_flags = [ "nodejs_als" ]on in yourwrangler.toml, otherwise you risk request bleeding (we requireAsyncLocalStorageto do isolation).If you don't want any
node_compat, we can't do the globalwithSentrymagic function, so you'll need to manually create a client.Unfortunately performance is not active here because the parent child relationship is wrong, so maybe we gate performance behind requiring
compatibility_flags = [ "nodejs_als" ]. The same also applies for automatic instrumentation adding breadcrumbs, we risk attaching to the wrong request. All automatic instrumentation (like automatically instrumenting d1 or r2 bindings) might be turned off if we cannot access asynclocalstorage.We also need to add support for Version metadata binding - I'm imagining this is easiest to expose as an
initconfig where you tell us what environmental variable to access for this info, and we automatically update releases and such.AbhiPrasad commentedon Jun 26, 2024
I'm throwing around some experiments in https://github.com/AbhiPrasad/sentry-cloudflare-test/tree/main/examples
ChristianJacobsen commentedon Jun 26, 2024
Hey @AbhiPrasad,
by adding support for Cloudflare Workers, do you also plan to add support for Cloudflare Pages? I know CF are working on unifying the two platforms, but it's still "a bit out there" (at least according to their Discord) and there are some subtle differences to how they work.
Anyways, awesome that you are doing this! 😄 I've been looking forward to official support for a long time!
AbhiPrasad commentedon Jun 26, 2024
Yes for sure, this is def part of it because this is how all the metaframework integrations work. Let me make it more clear in the tracking issue, and also add some example of API design for that too.
F0rce commentedon Jun 27, 2024
Does this include Astro? 👀 I know there is already an
@sentry/astrointegration (which is great), but the Cloudflare adapter (and Astro in SSR mode) is still not supported with it.Like everyone else said, im also super happy that this is being worked on :)
50 remaining items
KyGuy2002 commentedon Sep 3, 2024
No worries, thanks for the update 👍
feat(platforms): Add cloudflare platform to backend (#77769)
chore: Remove alpha note from cloudflare readme (#13728)
CameronB15 commentedon Apr 1, 2025
Hi all, it's great to see Cloudflare Workers getting some attention. Cloudflare seem to be moving towards the WorkerEntrypoint/class-based approach. E.g., RPC methods (worker-to-worker requests) are only supported with WorkerEntrypoint: https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/#the-workerentrypoint-class
Are there plans to support this structure?
AbhiPrasad commentedon Apr 1, 2025
@CameronB15 I created #15942 to track this!