Cloudflare Workflows

Learn how to add Sentry instrumentation for Cloudflare Workflows.

(Available in version 9.32.0 and above)

The Sentry Cloudflare Vite plugin instruments your Cloudflare Workflows automatically. It reads the Workflow classes from your wrangler config and wraps each one at build time with the options from your instrument.server.* file. You don't have to change your code.

If you deploy with wrangler directly, wrap each class yourself with instrumentWorkflowWithSentry, as shown in the Wrangler setup.

Because workflows can be hibernated and lose all state, we use the workflows instanceId to generate the Sentry trace_id to link all steps together into a single trace. If instanceId is a UUID (with or without dashes), it will be used directly as the trace_id. If not, we SHA1 hash the instanceId to generate a deterministic trace_id.

We use the last 4 characters of the trace_id for sampling to ensure all steps have the same sampling decision.

Because the instanceId is used for both the trace_id and for sampling decisions, you should ensure that the instanceId is unique for each workflow instance. If you are using custom UUIDs, you should ensure the last 4 digits are sufficiently random to ensure a good distribution of sampling decisions.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").