Skip to content

Support new SvelteKit tracing feature #16982

@Lms24

Description

@Lms24

Currently testing a preview of SvelteKit's new tracing feature. This issue will eventually collect all steps we need to take to ensure compatibility with Kit's new feature as well as with kit versions where it is not enabled or not yet available.

For now, I'm just noting down some stuff but we'll extract that to proper sub issues later.

Step 1: Establish Compatibility

  • sentryHandle should not create a span or isolate requests if event.tracing.enabled is true (thanks for including the tracing info on the event @elliott-with-the-longest-name-on-github 🙏 )
    • Which begs the question: Do we need it at all? We do capture errors in it but we'd likely capture them as well in an outer context via our general instrumentation. Let's ensure it doesn't break the experience for tracing first and then re-evaluate.
  • Right now, even with sentryHandle turned off, it seems like sveltekit.handle.root become root spans but not child spans of the http span coming from our/OTel's HttpInstrumentation. Tested on Node adapter. Need to check if we can fix this or if this needs a fix in kit.
  • In general, one request now creates multiple root spans. I'm suspecting our request isolation to be at fault but not sure yet how to fix.
    • The good news is that they're all trace-connected.
    • The bad news is that sentry's transaction model is problematic here, given each root span creates a new transaction. Increases billing (potentially). We need to fix this somehow.
  • Write a guide how to set up the SDK with Kit's tracing enabled.

Step 2: Full Support

  • ensure our build time auto instrumentation doesn't apply since Kit does this now 🎉 In a first step, we'll instruct users to set autoInstrument: false in our vite plugin but long term, we should be able to read the tracing config automatically from svelte.config.js
  • Process spans from Kit to include sentry.op and sentry.origin attributes.
  • Ensure root http.server span (HttpInstrumentation) picks up correct route name.
  • Deprecate wrap(Server)LoadWithSentry and wrapApiRouteWithSentry. The migration path for users is upgrading to kit and enabling tracing. But we'll not drop support for older Kit versions anytime soon.
  • Update docs with the final config

Metadata

Metadata

Assignees

Labels

TracesjavascriptPull requests that update javascript code

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions