Closed
Improvement
Description
Problem Statement
In our server-side http.server
instrumentation for SvelteKit (via the sentryHandle
hook handler), we decide if we should create a new execution context based on the presence of an active span. I've seen cases w4here this doesn't work properly and just discovered that since SvelteKit 1.21.0, the request event actually exposes an isSubRequest
flag telling us if the incoming event is a sub-request of another server request.
This flag was introduced in sveltejs/kit#10170 and released with v1.21.0
Example:
- User navigates to a page w/ a server load function
sentryHandle
hook is executed for the initial request from the client to execute the load function (soisSubRequest === false
). In this case we should create a new isolation scope/execution context- load function calls
fetch('/api/data')
sentryHandle
hook is executed again, but this time,isSubRequest === true
- This time, we shouldn't create a new execution context
Solution Brainstorm
Check for presence of isSubReques
and if present, decide on this flag. Otherwise decide on active span as previously.