You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of today, server-side OpenTelemetry-backed instrumentation does not correctly work in our @sentry/sveltekit SDK. This is caused by us initializing the SDK in hooks.server.ts; a file that is imported fairly at the beginning of the SvelteKit server app lifecycle. However, given the ESM nature of SvelteKit, the SDK initialization still needs to happen earlier.
As of today:
No Otel-based instrumentation works (e.g. DB spans)
Users get http.server spans from our own instrumentation (via the sentryHandle request handler)
Users get spans for load functions via our build time auto instrumentation.
Users get http.client spans, due to Undici fetch using diagnostics channels
Request isolation works due to our instrumentation creating an isolation scope
Solution Brainstorm
There are two (three) ways we can achieve an early enough initialization so that Otel-based instrumentation works:
making users --import an SDK initialization file like in our Node SDK. This will work for the Node adapter but not in envs like Vercel where you can't specify --import.
adding native support for instrumentation to SvelteKit and its adapters, like NextJS does with its instrumentation.ts file. I took a stab at this over the holidays and got first results. This will require coordination with the svelte team but I believe it's the only fully sustainable way of ensuring a proper instrumentation architecture that will work on all platforms.
[haven't thought this through] perhaps we can hack a dynamic import of the server app into the SvelteKit build which means that we first import our SDK init code and then dynamically import the server app code. It's uncertain if this works reliably and we ran into multiple problems when trying this in the Nuxt SDK.
Once we've found a way to support Otel in SvelteKit, these are the concrete tasks we need to solve:
The content you are editing has changed. Please copy your edits and refresh the page.
Importantly, we need to remain backwards-compatible with the current way of setting up the SDK as long as we don't release work in this issue with a new major version. We are free to deprecate anything that we deem to be removed in a future SDK version.
The text was updated successfully, but these errors were encountered:
Problem Statement
As of today, server-side OpenTelemetry-backed instrumentation does not correctly work in our
@sentry/sveltekit
SDK. This is caused by us initializing the SDK inhooks.server.ts
; a file that is imported fairly at the beginning of the SvelteKit server app lifecycle. However, given the ESM nature of SvelteKit, the SDK initialization still needs to happen earlier.As of today:
http.server
spans from our own instrumentation (via thesentryHandle
request handler)load
functions via our build time auto instrumentation.http.client
spans, due to Undici fetch using diagnostics channelsSolution Brainstorm
There are two (three) ways we can achieve an early enough initialization so that Otel-based instrumentation works:
--import
an SDK initialization file like in our Node SDK. This will work for the Node adapter but not in envs like Vercel where you can't specify--import
.instrumentation.ts
file. I took a stab at this over the holidays and got first results. This will require coordination with the svelte team but I believe it's the only fully sustainable way of ensuring a proper instrumentation architecture that will work on all platforms.Once we've found a way to support Otel in SvelteKit, these are the concrete tasks we need to solve:
Tasks
Importantly, we need to remain backwards-compatible with the current way of setting up the SDK as long as we don't release work in this issue with a new major version. We are free to deprecate anything that we deem to be removed in a future SDK version.
The text was updated successfully, but these errors were encountered: