Skip to content

Conversation

logaretm
Copy link
Collaborator

@logaretm logaretm commented Oct 8, 2025

Adds Nitro/Nuxt Cache API instrumentation by building upon the storage instrumentation in #17858 since both use unstorage under the hood.

How it works

Nitro injects the cache storage on either cache: or the root mount depending on user configuration, also in production the cache storage is placed on the root mount unless the user configures it explicitly to redis or something else. We instrument both mount drivers to cover other cache use cases.


I made sure to add e2e tests as well for cachedEventListner and cachedFunction calls which are the main ways to use the Cache API.

This PR depends on the storage PR #17858.

Copy link
Contributor

github-actions bot commented Oct 8, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.4 kB added added
@sentry/browser - with treeshaking flags 22.9 kB added added
@sentry/browser (incl. Tracing) 40.61 kB added added
@sentry/browser (incl. Tracing, Replay) 78.98 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.62 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 83.67 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 95.82 kB added added
@sentry/browser (incl. Feedback) 41.1 kB added added
@sentry/browser (incl. sendFeedback) 29.06 kB added added
@sentry/browser (incl. FeedbackAsync) 33.97 kB added added
@sentry/react 26.11 kB added added
@sentry/react (incl. Tracing) 42.55 kB added added
@sentry/vue 28.92 kB added added
@sentry/vue (incl. Tracing) 42.39 kB added added
@sentry/svelte 24.44 kB added added
CDN Bundle 26.63 kB added added
CDN Bundle (incl. Tracing) 41.15 kB added added
CDN Bundle (incl. Tracing, Replay) 77.44 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 82.9 kB added added
CDN Bundle - uncompressed 78.18 kB added added
CDN Bundle (incl. Tracing) - uncompressed 122.18 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 237.34 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 250.1 kB added added
@sentry/nextjs (client) 44.58 kB added added
@sentry/sveltekit (client) 40.98 kB added added
@sentry/node-core 50.74 kB added added
@sentry/node 154.36 kB added added
@sentry/node - without tracing 92.59 kB added added
@sentry/aws-serverless 106.32 kB added added
@logaretm logaretm marked this pull request as ready for review October 8, 2025 13:24
@logaretm logaretm requested review from andreiborza and s1gr1d October 8, 2025 13:25
cursor[bot]

This comment was marked as outdated.

@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from 64e5814 to 42ef2c7 Compare October 9, 2025 09:02
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 09e73ad to 4f26f70 Compare October 9, 2025 09:02
* Checks if the cache entry is a response cache entry.
*/
function isResponseCacheEntry(key: string, _: CacheEntry): _ is CacheEntry<ResponseCacheEntry & { status: number }> {
return key.startsWith('nitro:handlers:');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be checked with CACHED_FN_HANDLERS_RE here as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not here no, we want to be able to distinguish between cachedFunction and cachedEventHandler cached entries here, the regex detects if it is either.

The reason for the distinction is we want to apply more checks if it is a cached response entry since Nitro employs more checks in that case that would determine the cache validity.

@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from ab3ecc1 to d943f7d Compare October 10, 2025 10:51
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 1c23b89 to f2ad9e7 Compare October 10, 2025 10:53
cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants