Repository navigation
feat(nuxt): Instrument Nitro v3 cache storage - #25951
Draft
sentry-junior[bot] wants to merge 2 commits into
Draft
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
Nitro v3 keeps cached functions and handlers in an ocache storage that only goes through KV storage with the `kv` cache driver, so the default `memory` and the `fs` drivers produced no cache spans. Wrap the storage that the `#nitro/virtual/cache` module creates at build time. Co-Authored-By: Francesco Gringl-Novy <francesco.novy@sentry.io>
Contributor
size-limit report 📦Compared: 6ac1b5c (PR test merge using fix/nuxt-5-nitro-rc at 24d8402) Against: 7aca628 (fix/nuxt-5-nitro-rc) · base run #64423
|
Contributor
Optional E2E testsAll optional checks were successful. 4 successful. See the run. Successful checks
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: Starting with the RC, Nitro v3 runs
defineCachedFunction/defineCachedHandler(andcacheroute rules) on anocachestorage. That storage only goes through KV storage when thekvcache driver is set, so with the defaultmemorydriver (and withfs) our KV driver instrumentation never sees cache reads or writes, and nocache.*spans are produced. Nitro doesn't offer a tracing channel for its cache, and the storage instance is private to Nitro's runtime. It is created in the build-time#nitro/virtual/cachemodule, though, so a bundler transform wraps that module'screateCacheStorageexport and the storage gets patched in place. It has to be patched in place becauseocachealso readsbinaryandmaxEntryBytesfrom the storage object. Thekvdriver is skipped because the existing KV instrumentation already covers it.cache.hitcomes from the stored entry: it must have a value, be unexpired, and not be markedstale. This PR also undoes thekvworkaround in the nuxt-5 E2E app, so the default driver is what gets tested.How to review: Start with
cacheStorageInstrumentationPlugininvite/storageConfig.ts, theninstrumentCacheStorageinruntime/utils/instrumentStorage.ts. The span wrapper is now shared with the KV driver instrumentation, and KV behavior is unchanged.Unsure about: The transform matches the exact
export const createCacheStorage =line that Nitro generates. If Nitro changes that template, the transform does nothing (no crash), but cache spans would disappear again. Is that acceptable, or should we push upstream for a tracing channel or hook in Nitro/ocache? Note this is stacked on #25949.via Francesco Gringl-Novy.
--
View Session [Sentry]