Repository navigation
feat(cloudflare): Add incoming request span options to httpServerIntegration - #25582
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f8fed4d. Configure here.
size-limit report 📦Compared: 56fab70 (PR test merge using develop at f2434ff) Against: b3e0c9e (develop) · base run #63030
|
97cb62a to
a96f52e
Compare
a96f52e to
2ceb825
Compare
2ceb825 to
227d2e4
Compare
JPeer264
left a comment
There was a problem hiding this comment.
Code looks good overall. Just not approving yet until the one comment is clarified
| * Whether to create a span for the incoming request, based on the HttpServer integration config. | ||
| * Called internally by `wrapRequestHandler`. | ||
| */ | ||
| export function shouldCreateIncomingRequestSpan(client: Client | undefined, request: Request): boolean { |
There was a problem hiding this comment.
There was a problem hiding this comment.
Same answer, I guess. We should either do this for all 3, or none of them, but Node already behaves this way, and it seems low risk.
In fact, for Cloudflare, this affects even less traffic, since typically the Worker typically won't be responsible for serving static files anyway, I would imagine?
In any event, we should definitely keep the machinery, and either leave the default on all three true (to match node) or false (to prevent a behavior change, and flip to true in v12).
Probably the sensible way to approach this is another deliberate PR on top of (or after) this stack, which sets the default to false, if that's how we want to go.
227d2e4 to
9703086
Compare
Optional E2E testsSome optional checks were not successful. They do not block the merge. 10 failing, 22 successful. See the run.
Successful checks
|
9703086 to
3dc6a19
Compare
3dc6a19 to
8e70a78
Compare
8e70a78 to
0df3e5e
Compare
47f73c6 to
931b7ed
Compare
…egration` Cloudflare's `httpServerIntegration` took only the body capture options. A user could not skip spans for one route, such as a health check, or change the request span from the request or the response. Node, Deno and Bun all allow this. `httpServerIntegration` now accepts `ignoreIncomingRequests`, `ignoreStaticAssets`, `spans`, `onSpanCreated` and `onSpanEnd`. They use the same names and behavior as `denoServeIntegration` and `bunServerIntegration`, and the callbacks receive the web `Request`. The shared `ServerRequestOptions` check for Cloudflare now lists only the session options, which a worker cannot support because it has no long-lived process to run the flush timer. When the SDK skips the span, it still continues the incoming trace, attaches request data and the body, and captures errors. It also still waits for a streamed response to finish before it flushes. For a streamed response, `onSpanEnd` runs when the stream finishes. It does not run when the handler throws. A callback that throws does not fail the request. `ignoreRequestBody` also no longer fails the request when it throws. The SDK skips the body instead, so it cannot leak data that the filter was meant to hide. Deno and Bun already do this. Two defaults change behavior: - `ignoreStaticAssets` defaults to `true`, so `GET` requests for files such as `favicon.ico` or `*.js` no longer create spans. - `spans` defaults to the client's tracing configuration, so the SDK no longer starts request spans when tracing is disabled. Fixes #25573 Fixes JS-3971 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
931b7ed to
6d40485
Compare

Cloudflare's
httpServerIntegrationtook only the body capture options. A user could not skip spans for one route, such as a health check, or change the request span from the request or the response. Node, Deno and Bun all allow this.httpServerIntegrationnow acceptsignoreIncomingRequests,ignoreStaticAssets,spans,onSpanCreatedandonSpanEnd. They use the same names and behavior asdenoServeIntegrationandbunServerIntegration, and the callbacks receive the webRequest. The sharedServerRequestOptionscheck for Cloudflare now lists only the session options, which a worker cannot support because it has no long-lived process to run the flush timer.When the SDK skips the span, it still continues the incoming trace, attaches request data and the body, and captures errors. It also still waits for a streamed response to finish before it flushes. For a streamed response,
onSpanEndruns when the stream finishes. It does not run when the handler throws. A callback that throws does not fail the request.ignoreRequestBodyalso no longer fails the request when it throws. The SDK skips the body instead, so it cannot leak data that the filter was meant to hide. Deno and Bun already do this.Two defaults change behavior:
ignoreStaticAssetsdefaults totrue, soGETrequests for files such asfavicon.icoor*.jsno longer create spans.spansdefaults to the client's tracing configuration, so the SDK no longer starts request spans when tracing is disabled.Fixes #25573
Fixes JS-3971