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
Following up after a meeting with @pi0, we recently at Sentry built and shipped KV storage instrumentation in the Nuxt SDK and had some discussion on a better way to implement it with tracing channels.
Current Solution: Monkey Patching
In the current solution we iterate over the defined mounts via getMounts and instrument each driver by monkey patching select methods on it and reporting various span attributes depending on the method called and the driver being used.
Here is a snippet of the relevant part:
// Get all mounted storage driversconstmounts=storage.getMounts();for(constmountofmounts){// Skip excluded mounts and root mountif(!userMounts.has(mount.base)){continue;}instrumentDriver(mount.driver,mount.base);}// Wrap the mount method to instrument future runtime mountsstorage.mount=wrapStorageMount(storage);
This isn't ideal as it is based on the assumption that the user may have exactly one storage instance, which is mostly true for Nuxt apps which is exposed via useStorage on toolkits like Nitro's.
This means unstorage API allows them to define multiple storage instances with createStorage, so storage instances created in runtime in that way would not be instrumented if they happen to use different drivers.
This solution is live right now in Nuxt SDK, and was going to be part of Nitro SDK which we shelved for now in order to see the outcome of making use of tracing channels around Nitro first.
Proposal: Tracing Channels
Tracing channels are an experimental Node API that is available since 18.19 and 19.9 and it is already being used by other libraries in the ecosystem.
The main idea here is to fire events to an unstorage tracing channel, something like this:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Following up after a meeting with @pi0, we recently at Sentry built and shipped KV storage instrumentation in the Nuxt SDK and had some discussion on a better way to implement it with tracing channels.
Current Solution: Monkey Patching
In the current solution we iterate over the defined mounts via
getMountsand instrument each driver by monkey patching select methods on it and reporting various span attributes depending on the method called and the driver being used.Here is a snippet of the relevant part:
This is great to avoid having to instrument each driver individually, you can find the instrumentation code itself around starting spans here.
This isn't ideal as it is based on the assumption that the user may have exactly one storage instance, which is mostly true for Nuxt apps which is exposed via
useStorageon toolkits like Nitro's.This means
unstorageAPI allows them to define multiple storage instances withcreateStorage, so storage instances created in runtime in that way would not be instrumented if they happen to use different drivers.This solution is live right now in Nuxt SDK, and was going to be part of Nitro SDK which we shelved for now in order to see the outcome of making use of tracing channels around Nitro first.
Proposal: Tracing Channels
Tracing channels are an experimental Node API that is available since
18.19and19.9and it is already being used by other libraries in the ecosystem.The main idea here is to fire events to an
unstoragetracing channel, something like this:Then subscribers, like an instrumentation library could potentially use it like so:
We can discuss the details here and work towards a good proposal for it.
Potential Concerns
unstoragealso supports the browser via a driver, so a tracing channel wouldn't exist there.Beta Was this translation helpful? Give feedback.
All reactions