Skip to content

Use new isSubRequest flag in sentryHandle to decide on new root span creation  #11125

@Lms24

Description

@Lms24

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:

  1. User navigates to a page w/ a server load function
  2. sentryHandle hook is executed for the initial request from the client to execute the load function (so isSubRequest === false). In this case we should create a new isolation scope/execution context
  3. load function calls fetch('/api/data')
  4. sentryHandle hook is executed again, but this time, isSubRequest === true
  5. 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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions