Skip to content

Commit dffd0ee

Browse files
authored
docs(cloudflare): Add notice about spans Workflows (#14880)
## DESCRIBE YOUR PR Adds notice about rather not creating spans outside of `step.do` mentioned in this PR: getsentry/sentry-javascript#17582 ref: getsentry/sentry-javascript#17419 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
1 parent bd9befa commit dffd0ee

File tree

1 file changed

+9
-2
lines changed
  • docs/platforms/javascript/guides/cloudflare/features

1 file changed

+9
-2
lines changed

docs/platforms/javascript/guides/cloudflare/features/workflows.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ Because workflows can be hibernated and lose all state, we use the workflows
1212
`instanceId` to generate the Sentry `trace_id` to link all steps together into a
1313
single trace. If `instanceId` is a UUID (with or without dashes), it will be
1414
used directly as the `trace_id`. If not, we SHA1 hash the `instanceId` to
15-
generate a deterministic `trace_id`.
15+
generate a deterministic `trace_id`.
1616

1717
We use the last 4 characters of the `trace_id` for sampling to ensure all steps
18-
have the same sampling decision.
18+
have the same sampling decision.
1919

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

25+
<Alert level='warning'>
26+
We recommend creating spans only inside `step.do()` callbacks. Due to the nature of Cloudflare Workflows, a workflow
27+
can be hibernated and resumed at any point. When a workflow resumes, its `run` method is executed again from the beginning.
28+
`step.do()` calls are idempotent and won't re-run completed steps, but any code outside of them will be re-executed.
29+
This can lead to duplicated spans and unexpected behavior if you start spans at the top level of your `run` method.
30+
</Alert>
31+
2532
```typescript
2633
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent } from 'cloudflare:workers';
2734
import * as Sentry from "@sentry/cloudflare";

0 commit comments

Comments
 (0)