GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(cloudflare)!: Replace enableRpcTracePropagation with rpcTracePropagationBindings by JPeer264 · Pull Request #23486 · getsentry/sentry-javascript Conversation
|
size-limit report 📦
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bugbot run |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d68e2df. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d68e2df to
74e4152
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This mostly looks good, and does solve the intended problem. I think there's an improvement that ought to be done to make the gating match what the comment says, and a possible improvement to match core's trace propagation RegExp handling, but once those are addressed (or dismissed for good reason) then lgtm.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * Propagation over `stub.fetch()` and service binding `fetch()` uses HTTP headers and is not | ||
| * affected by this option. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I could be misreading this, but it says here that it's not gating on this option, but then in instrumentEnv in packages/cloudflare/src/instrumentations/worker/instrumentEnv.ts on line 97, it does this:
if (!shouldPropagateRpcTrace(String(prop))) { return item; }
which is where it uses this option, and that's before the instrumentDurableObjectNamespace(item) and instrumentFetcher calls. So I think it is affected by this option, then, and maybe shouldn't be?
Suggestion: always apply instrumentDurableObjectNamespace and the JSRPC fetch wrap, and move shouldPropagateRpcTrace(...) down so it guards only the appendRpcMeta decision, to around instrumentEnv.ts line 117 and the equivalent call in instrumentDurableObjectNamespace.ts on line 55.
That'll need the binding name threaded into instrumentDurableObjectNamespace, but that's a pretty minor change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That is an insane catch tbh! It's a good idea to always apply it on fetch calls, as this wouldn't break anything, even on uninstrumented workers. The actual RPC calls are the issue - I'll update that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| // Strings must match a binding name exactly, without this, an entry of `DB` would also enable | ||
| // propagation for a binding named `MY_DB`. Regular expressions still give pattern matching. | ||
| return (bindingName: string) => stringMatchesSomePattern(bindingName, targets, true); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This should probably get the same defensive fix as core did in ee5a772, so that /g and /y flags don't mess things up. Either use matchesTracePropagationTargets (which is for this purpose) or call normalizeRegExpTarget like it does.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh, also, this should be case-insensitive if the goal is to match tracePropagationTargets, since it became case insensitive in that commit as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this should be case-insensitive if the goal is to match tracePropagationTargets, since it became case insensitive in that commit as well.
Yes I totally. I planned this to be in a separate PR so this PR can be backported to v10 with the same functionality and the case-insensitive change lives only in v11. Will prepare that today.
so that /g and /y flags don't mess things up
that is a good point, I would have missed that. Same as above I'll keep that in v11 to match things properly
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
follow-up PR: #23625
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| if (!options?.enableRpcTracePropagation) { | ||
| if (!shouldPropagateRpcTrace(String(prop))) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
See the comment on client.ts, this should move down so that it only guards what the JSDoc comment says gates on it.
Suggestion: always apply
instrumentDurableObjectNamespaceand the JSRPCfetchwrap, and moveshouldPropagateRpcTrace(...)down so it guards only theappendRpcMetadecision, to aroundinstrumentEnv.tsline 117 and the equivalent call ininstrumentDurableObjectNamespace.tson line 55.That'll need the binding name threaded into
instrumentDurableObjectNamespace, but that's a pretty minor change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Covered with #23486 (comment)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return isObjectLike(item) || typeof item === 'function'; | ||
| } | ||
|
|
||
| const instrumentedBindings = new WeakMap<object, unknown>(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is shared across all envs, so it can leak to everything in the same isolate. Could be a problem, since this method is called from a bunch of different places, each with its own options object.
Recommend: key the cache on (binding, decision) or move it inside the per-instrumentEnv closure.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify that I think I can't follow on this. What is an "env" in this case? In practice each DurableObject, Workflow and WorkerEntrypoint to have separate isolates (at least with my tests on prod) and they do not share any memory - so in practice the options wouldn't change. If I read it correctly this comment would only be true if two DurableObjects with different options.rpcTracePropagationBindings occur on one isolate, right?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ); | ||
| ``` | ||
|
|
||
| - The `instrumentPrototypeMethods` option of `instrumentDurableObjectWithSentry` was removed. A Durable Object instruments its RPC methods unconditionally now, so there is nothing to replace it with on the receiver. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend adding a note here that a Durable Object's prototype methods are now replaced unconditionally, rather than just "there is nothing to replace it with on the receiver", because that sounds a bit like "nothing happens".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is being used as just a presence test, so it could use hasRpcMeta no?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This logic is now gone, so we don't check for that anymore. I'm using the "check" from inside wrapMethodWithSentry now
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Combined with ac98cbb
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return captureMethod; | ||
| } | ||
|
|
||
| const tracedMethod = wrapMethodWithSentry( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
low/question: Previously this method was only generated lazily, if the RPC trace prop was enabled, but now it's being built every time. Is it possible/worthwhile to generate both lazily, since only one of them ends up being used?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hm. I just realized that tracedMethod is kinda the same as boundMethod above, so it could be combined into one
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * ``` | ||
| */ | ||
| enableRpcTracePropagation?: boolean; | ||
| rpcTracePropagationTargets?: Array<string | RegExp>; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This could use the TracePropagationTargets type from core, clearer communication of intent.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh, also, this is kind of confusingly named, since it's not matched against URLs, but just against binding env strings? Consider: rpcTracePropagationBindings
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This could use the TracePropagationTargets type from core, clearer communication of intent.
Makes sense. I'll use that one
this is kind of confusingly named, since it's not matched against URLs, but just against binding env strings? Consider: rpcTracePropagationBindings
That is an amazing name. Love it!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
8a2c709 to
7e69829
Compare
Sorry, something went wrong.
There was an error while loading. Please reload this page.
862d405 to
f6bdbcb
Compare
|
👋 @andreiborza — Please review this PR when you get a chance! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| // Strings must match a binding name exactly, without this, an entry of `DB` would also enable | ||
| // propagation for a binding named `MY_DB`. Regular expressions still give pattern matching. | ||
| return (bindingName: string) => stringMatchesSomePattern(bindingName, bindings, true); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
m: for core tracePropagationTargets, we'll make string matches case-insensitive. (#16018) Can/should we do the same for rpcTracePropagationBindings? My thinking is this is less of an issue but might make sense to align. But happy to let you make the call on it. I'm fine with both
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes it makes sense, but not for this PR. The plan is to backport this PR back to v10 - where there is no case-insensitivity for tracePropagationTargets yet. Further up in the stack we'll add that and match the behavior: #23625
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * - `stub.fetch()` calls to Durable Objects (via HTTP headers) | ||
| * - Service binding `fetch()` calls (via HTTP headers) | ||
| * - RPC method calls to Durable Objects and WorkerEntrypoints (via trailing argument) | ||
| * Strings match a binding name exactly, regular expressions match by pattern. An empty array |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
IF we make the case insensitivity adjustments, this JSDoc needs updating (see other comment)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should be covered by that in the other stacked PR: https://github.com/getsentry/sentry-javascript/pull/23625/changes#diff-f4da9e8be066d1d8bf57ee5f703f4a2484f478e60f7235e9c93cc5ad3694ba38R339-R340
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * (its own Durable Objects, its self service bindings) are added for you, because the plugin | ||
| * instruments those receivers itself. Whatever you list here is added on top of them. | ||
| * | ||
| * @default [] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
wild idea / no action required: I guess we have considered defaulting to undefined and concluded that the potential breaking of ...args case is too strong to do it, right?
That's fine, just wanted to confirm.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
undefined would be to allow list all, which I'd like to prevent here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Dismissed the review as all comments were implemented
…pagationTargets `enableRpcTracePropagation: true` propagated trace context to every Durable Object namespace and service binding on `env`. RPC carries that context as a trailing argument, and only a Sentry-instrumented receiver strips it again, so any receiver the user does not own saw an extra argument. `rpcTracePropagationTargets` names the bindings to propagate to instead, mirroring `tracePropagationTargets`. Strings match a binding name exactly, regular expressions match by pattern. The option is now caller-only. Receivers no longer take a switch: a Durable Object instruments its RPC methods unconditionally, matching what a WorkerEntrypoint already did. `extractRpcMeta` only strips a trailing argument that actually carries `__sentry_rpc_meta__`, so a call arriving without metadata is untouched. BREAKING CHANGE: `enableRpcTracePropagation` is removed. Replace it on the caller with `rpcTracePropagationTargets` listing the bindings you call, and drop it from receivers. Co-Authored-By: Claude Opus 5 <[email protected]>
…racePropagationTargets
f6bdbcb to
3d7ccbe
Compare
There was an error while loading. Please reload this page.
Backport of: #23486 ## Differences to the original PR - `packages/cloudflare/src/client.ts`: `enableRpcTracePropagation` is kept and deprecated instead of removed, so this is not a breaking change on v10. `rpcTracePropagationBindings` is added next to it. - `packages/cloudflare/src/utils/rpcPropagation.ts`: the resolver falls back to the existing `getEffectiveRpcPropagation(options)` chain (`enableRpcTracePropagation`, then the deprecated `instrumentPrototypeMethods`) only when `rpcTracePropagationBindings` is left unset. Setting the option wins over both, an empty array included: `enableRpcTracePropagation: true, rpcTracePropagationBindings: []` is a receiver that continues incoming traces and propagates to nothing itself. Treating `[]` as unset would leave that worker propagating to every binding, which is #23233 again for anyone who set it to opt out of sending. - The receiver side is unchanged. `packages/cloudflare/src/durableobject.ts`, `packages/cloudflare/src/instrumentations/instrumentWorkerEntrypoint.ts` and `packages/cloudflare/src/wrapMethodWithSentry.ts` keep their v10 behaviour, so a Durable Object or WorkerEntrypoint still needs `enableRpcTracePropagation: true` to continue an incoming trace and to instrument its RPC methods. The original PR made that unconditional, which required removing `instrumentPrototypeMethods` as well. - Because of that, the receiver-side `enableRpcTracePropagation: true` was kept in every integration and E2E test app; only the caller-side option was replaced with `rpcTracePropagationBindings`. - `MIGRATION.md` gets no entry, there is nothing to migrate on v10. - `packages/cloudflare/test/options.test-d.ts` does not exist on v10, so its changes were dropped.
<!-- Keep the urgency section so automation can prioritize this PR. You may delete other sections you don't need. --> ## DESCRIBE YOUR PR This describes getsentry/sentry-javascript#23486 and fixes the main concern of getsentry/sentry-javascript#23233 I tried to burry `enableRpcTracePropagation` as much as possible in favor of `rpcTracePropagationBindings` - so `enableRpcTracePropagation` is still documented as options, but has huge drawbacks - `rpcTracePropagationBindings` is a safe alternative and it's best if we only document this. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the due date. You can update this information later by editing the PR description. - [x] Urgent deadline (GA date, etc.): 2026-09-02 - It has been released already. Do not confuse more people with the old option, the new option would be nice to be documented - [ ] Other deadline: YYYY-MM-DD - [ ] No deadline: 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 supplied a deadline. 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) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Sigrid <[email protected]>
…PC calls (#24512) Backport of: #24447 ## Differences to the original PR - `packages/cloudflare/src/wrapMethodWithSentry.ts`: added the `spanName` resolver (`string | (rpcMeta) => string | undefined`) from #23486. The fix depends on it to skip the span for untraced calls, and v10 only accepts a string. - `packages/cloudflare/src/durableobject.ts`: kept the v10 `alwaysTrace` path for the deprecated `instrumentPrototypeMethods` option unchanged (every call, internal ones included, gets an `rpc` span). The new capture-only path applies only with `enableRpcTracePropagation`. Uses `'rpc'` instead of `RPC` from `@sentry/conventions`, which v10 does not depend on. The JSDoc keeps the v10 note that RPC methods are instrumented only with `enableRpcTracePropagation`. - `packages/cloudflare/test/durableobject.test.ts`, `suites/durableobject/rpc-without-trace/index.ts`: set `enableRpcTracePropagation: true`, because v10 does not instrument RPC methods by default. - `suites/tracing/propagation/worker-do-rpc-overlapping/vite.config.mts`: set `_experimental: { autoInstrumentation: true }`, because Vite auto-instrumentation is opt-in on v10. On v10 the fix therefore covers Durable Objects with `enableRpcTracePropagation: true` (the setup from #24443). Without that option, v10 does not instrument RPC methods at all, same as before. Co-authored-by: Mark Snelling <[email protected]>
…25306) 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` (#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 --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Cloudflare RPC trace propagation changes method arguments for uninstrumented receivers
There was an error while loading. Please reload this page.