Skip to content

[Cloudflare workflows] Dedicated span do not show up in error reports #17419

Closed

Description

@Mael-Abgrall

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare

SDK Version

10.3.0

Framework Version

No response

Link to Sentry event

https://ansearch.sentry.io/traces/trace/490b74c4ebdf422880ad494ec5500f27/?end=2025-08-16T01%3A23%3A57&mode=samples&node=span-bca03ce942e255f4&pageEnd=Sat%20Aug%2016%202025%2002%3A23%3A57%20GMT%2B0100%20%28British%20Summer%20Time%29&pageStart=Wed%20Aug%2013%202025%2002%3A23%3A57%20GMT%2B0100%20%28British%20Summer%20Time%29&project=-1&query=trace%3A490b74c4ebdf422880ad494ec5500f27&source=traces&start=2025-08-13T01%3A23%3A57&statsPeriod&table=trace&timestamp=1755178643.709

Reproduction Example/SDK Setup

Nested manual spans as described here: https://docs.sentry.io/platforms/javascript/guides/cloudflare/tracing/span-metrics/#creating-dedicated-metric-spans are not showing up in error traces.

I'm facing some deep issues in my workflows, and using the spans to debug what is happening. To do so, I'm nesting spans (one span for multiple step.do that are related)

The issue is none of those nested span are showing up in the dashboard, making it impossible to track what is going on

Steps to Reproduce

class WorkflowIngestBase extends WorkflowEntrypoint<
  Cloudflare.Env,
  IngestionWorkflowParameters
> {
  async run(
    event: WorkflowEvent<IngestionWorkflowParameters>,
    step: WorkflowStep,
  ): Promise<void> {
    const page = step.do('fetch page'() => {...})

    for (const item in page.item){
      Sentry.startSpan(
        {
          name: 'my custom span',
          attributes: {
            pageID: page.id,
          }
        },
        async () => {
          await step.do('process page item', async () => {...})
          await step.do('save item', async () => {...})
        }
      );
    }
  }
}

export const WorkflowIngest = SentryCloudflare.instrumentWorkflowWithSentry(
  (_environment: Cloudflare.Env) => {
    return {
      dsn: '...',
      ...customSentryConfig,
    };
  },
  WorkflowIngestBase,
);

Expected Result

(in Sentry)

Trace
|- step.do fetch page
|- my custom span
| |- step.do process item
| |- step.do save item
|- my custom span
| |- step.do process item
| |- step.do save item
| ...

Actual Result

(in Sentry)

Trace
|- step.do fetch page
|- step.do process item
|- step.do save item
|- step.do process item
|- step.do save item

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 14, 2025
  2. Lms24 commented on Aug 18, 2025

    @Lms24
    Member

    Hey @Mael-Abgrall thanks for writing in! Quick heads-up: We're having an internal hackathon this week ("Hackweek"). Therefore, we'll likely only look at this next week in detail.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Aug 18, 2025
  4. self-assigned this
    on Sep 9, 2025
  5. s1gr1d commented on Sep 10, 2025

    @s1gr1d
    Member

    Hello, thanks for writing in!

    Our implementation was creating a new Sentry client for each step.do and that reseted the tracing context and the span started with startSpan was never exported to Sentry. I fixed this behavior in this PR and it should look like this when it is merged :)

    Image
  6. s1gr1d commented on Sep 11, 2025

    @s1gr1d
    Member

    In general, this is fixed in the next release but creating a span outside the workflow is not recommended.
    See this comment from the Cloudflare Workflow team: #17582 (comment)

    If you are pretty sure that your workflow won't hibernate, you can probably leave the "outer" startSpan.

    We'll also reflect this in the docs (PR): https://docs.sentry.io/platforms/javascript/guides/cloudflare/features/workflows/

  7. github-actions commented on Sep 16, 2025

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #17582, which was included in the 10.12.0 release.

  8. Mael-Abgrall commented on Sep 17, 2025

    @Mael-Abgrall
    Author

    @s1gr1d that is great insights, thank you for following up with cloudflare's team :)

    And I also did found out that errors outside of step.do where not caught

    fantastic thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions