Cloudflare Workflows
Learn how to add Sentry instrumentation for Cloudflare Workflows.
(Available in version 9.32.0 and above)
You can use the instrumentWorkflowWithSentry
method to instrument Cloudflare Workflows.
Because workflows can be hibernated and lose all state, we use the workflows instanceId
as the Sentry trace_id
to link all steps together. We also use the last 4 characters of the instanceId
for sampling to ensure all steps have the same sampling decision. If you are starting your workflows with a custom instanceId
, ensure you use valid random UUIDs either with or without dashes.
Copied
import {
WorkflowEntrypoint,
WorkflowStep,
WorkflowEvent,
} from "cloudflare:workers";
import * as Sentry from "@sentry/cloudflare";
class MyWorkflowBase extends WorkflowEntrypoint<Env, Params> {
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
await step.do("fetch data", async () => {
//
});
await step.do("process data", async () => {
//
});
}
}
// Export your named class as defined in your wrangler config
export const MyWorkflow = Sentry.instrumentWorkflowWithSentry(
(env: Env) => ({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
tracesSampleRate: 1.0,
}),
MyWorkflowBase,
);
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").
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").