Skip to content

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

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

feat(cloudflare): propagate tracing context through Queue messages#22303
arthurfiorette wants to merge 4 commits into
getsentry:developfrom
arthurfiorette:arthurfiorette/queue-links

Conversation

@arthurfiorette

@arthurfiorette arthurfiorette commented Jul 15, 2026

Copy link
Copy Markdown

Adds opt-in distributed tracing across Cloudflare Queue producers and consumers.

When enableQueueTracePropagation is enabled on both sides:

  • Record-like message bodies carry sentry-trace and baggage under __sentry_queue_meta__.
  • Arrays, binary payloads, and non-object payloads remain unchanged.
  • Consumers remove the transport metadata before invoking the application handler.
  • queue.process remains a root batch span and links to every producer represented in the batch.

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

The option is disabled by default because Cloudflare Queues does not expose a message-header API. Producers must modify record-like message bodies, so consumers without matching instrumentation may observe the additional metadata field.

Closes #22298

@arthurfiorette
arthurfiorette requested a review from a team as a code owner July 15, 2026 18:26
@arthurfiorette
arthurfiorette requested review from andreiborza, isaacs and mydea and removed request for a team July 15, 2026 18:26
Comment thread packages/cloudflare/src/instrumentations/worker/instrumentQueue.ts
Comment thread packages/cloudflare/src/utils/queueTraceMeta.ts
Comment thread packages/cloudflare/src/instrumentations/worker/instrumentQueue.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

There are 4 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0bd582c. Configure here.

Comment thread packages/cloudflare/src/utils/queueTraceMeta.ts Outdated
Comment thread packages/cloudflare/src/instrumentations/worker/instrumentEnv.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare Instrumentation for Queues seems broken

1 participant