Skip to content

feat(cloudflare): propagate tracing context through Queue messages - #25306

Open
arthurfiorette wants to merge 7 commits into
getsentry:developfrom
arthurfiorette:arthurfiorette/queue-links
Open

arthurfiorette wants to merge 7 commits into
getsentry:developfrom
arthurfiorette:arthurfiorette/queue-links

Conversation

@arthurfiorette

@arthurfiorette arthurfiorette commented Oct 13, 2026 •

Copy link
Copy Markdown

This extends #22303, which was auto-closed for inactivity after its review comments slipped through my GitHub inbox. It is now synced with develop and addresses that review.


Adds opt-in trace propagation from Cloudflare Queue producers to consumers.

  • When a producer binding matches queueTracePropagationBindings, plain-object message bodies carry the producer's sentry-trace under __sentry_queue_trace__.
  • Arrays, binary payloads and other non-plain values are sent unchanged.
  • Consumers remove that field before invoking the application handler.
  • queue.process remains a root span and links to every distinct producer in the batch.

Span links are used instead of continuing a producer trace because a Queue batch can contain messages from unrelated traces. Picking one producer as the parent would create false causal relationships for the other messages.

Propagation is opt-in per binding because Cloudflare Queues has no message-header API. The SDK has to modify the message body, so consumers without Sentry would see the extra field.

Changes since #22303:

  • enableQueueTracePropagation: boolean became queueTracePropagationBindings, mirroring rpcTracePropagationBindings (feat(cloudflare)!: Replace enableRpcTracePropagation with rpcTracePropagationBindings #23486). Only the producer opts in, since it is the side that changes the payload. Consumers always strip and link, the same way RPC receivers handle __sentry_rpc_meta__.
  • Links no longer set sentry.link.type: previous_trace. A batch fans in producers rather than forming a previous/next chain.

Fixes #22309

arthurfiorette and others added 6 commits July 15, 2026 15:25
- Replace `enableQueueTracePropagation` with `queueTracePropagationBindings`, matching
  `rpcTracePropagationBindings`: producers opt in per binding, consumers always strip and link.
- Drop the `previous_trace` link type, a batch fans in producers rather than chaining traces.
- Strip the carrier with `Reflect.deleteProperty` on the shared key so frozen bodies cannot throw.
- Compute the publish body size once when propagation is enabled.
- Move the queue integration assertions to span streaming.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the external PR from an external contributor label Oct 13, 2026
@arthurfiorette
arthurfiorette marked this pull request as ready for review October 13, 2026 03:47
@arthurfiorette
arthurfiorette requested a review from a team as a code owner October 13, 2026 03:47
@arthurfiorette
arthurfiorette requested review from JPeer264 and mydea and removed request for a team October 13, 2026 03:47
@Lms24

Lms24 commented Oct 13, 2026

Copy link
Copy Markdown
Member

HI @arthurfiorette thanks for opening another PR for this! I'll leave the review up to @JPeer264 who has more context on the cloudflare specific details.

Good idea to use span links. I think we should still set the sentry.link.type link attribute, but probably with the message_origin value as proposed here https://github.com/getsentry/sentry-javascript/pull/21777/changes#r4227878655. Unfortunately, that PR is not yet merged so we have to wait a bit for the final link type value. Shouldn't stop the rest of the review though :)

This branch has not been deployed

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

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare Queue context propagation and trace links

2 participants