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

linear bot commented Oct 8, 2025

Copy link
Contributor

github-actions bot commented Oct 8, 2025

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 24.64 kB - -
@sentry/browser - with treeshaking flags 23.14 kB - -
@sentry/browser (incl. Tracing) 40.99 kB - -
@sentry/browser (incl. Tracing, Replay) 79.29 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.98 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.16 kB - -
@sentry/browser (incl. Feedback) 41.33 kB - -
@sentry/browser (incl. sendFeedback) 29.3 kB - -
@sentry/browser (incl. FeedbackAsync) 34.26 kB - -
@sentry/react 26.35 kB - -
@sentry/react (incl. Tracing) 42.99 kB +0.02% +5 B 🔺
@sentry/vue 29.13 kB - -
@sentry/vue (incl. Tracing) 42.79 kB - -
@sentry/svelte 24.66 kB - -
CDN Bundle 26.94 kB - -
CDN Bundle (incl. Tracing) 41.65 kB - -
CDN Bundle (incl. Tracing, Replay) 77.89 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.35 kB - -
CDN Bundle - uncompressed 78.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 123.53 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.54 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251.31 kB - -
@sentry/nextjs (client) 45.06 kB - -
@sentry/sveltekit (client) 41.42 kB - -
@sentry/node-core 50.78 kB - -
@sentry/node 154.4 kB - -
@sentry/node - without tracing 92.65 kB - -
@sentry/aws-serverless 106.34 kB - -

View base workflow run

@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.

@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 759c029 to 65dae94 Compare October 13, 2025 09:31
@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from d943f7d to 83bb4e8 Compare October 13, 2025 09:32
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 65dae94 to c844c9e Compare October 13, 2025 09:32
@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from 83bb4e8 to f5cd0ca Compare October 15, 2025 10:31
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch 2 times, most recently from 17482e2 to 65277c7 Compare October 15, 2025 10:43
@logaretm logaretm requested a review from s1gr1d October 15, 2025 12:28
@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from 83e35f8 to d621605 Compare October 15, 2025 20:54
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 65277c7 to 604de80 Compare October 15, 2025 20:55
Base automatically changed from awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage to develop October 16, 2025 21:16
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 604de80 to f1dd874 Compare October 16, 2025 21:18
@logaretm logaretm merged commit 66dc9a2 into develop Oct 17, 2025
127 of 131 checks passed
@logaretm logaretm deleted the awad/js-1023-nuxtnitro-instrument-cache branch October 17, 2025 11:26
logaretm added a commit that referenced this pull request Oct 17, 2025
This pull request introduces automatic instrumentation for database
queries in Nuxt applications in server side handlers using Sentry.

#### Implementation Details

- Instruments database `.sql`, `.prepare` and `.exec` calls.
- Adds breadcrumbs and spans following cloudflare's D1 implementation.

This relies on the work done in #17858 and #17886
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants