Skip to content

Conversation

logaretm
Copy link
Collaborator

@logaretm logaretm commented Oct 3, 2025

What

This PR adds automatic instrumentation for Nuxt's storage layer (powered by unstorage), enabling performance monitoring for cache and key-value storage operations in Nuxt/Nitro applications.

Storage operations will now automatically create performance spans with detailed attributes for observability in Sentry.

What's New

  • Automatic Storage Instrumentation: Instruments all storage drivers configured in nuxt.config.ts via nitro.storage
  • Comprehensive Coverage: Tracks all storage operations including:
    • getItem, setItem, hasItem, removeItem
    • Raw variants: getItemRaw, setItemRaw
    • Batch operations: getItems, setItems
    • Utility methods: getKeys, clear
    • Aliases: get, set, has, del, remove

Implementation Details

Span Attributes:

  • sentry.op: cache.{operation} (e.g., cache.get_item, cache.set_item)
  • sentry.origin: auto.cache.nuxt
  • cache.key: Full key including mount prefix
  • cache.hit: true for successful get/has operations
  • nuxt.storage.op: Original method name
  • nuxt.storage.mount: Storage mount point
  • nuxt.storage.driver: Driver name (e.g., memory, fs, redis)

Files Changed:

  • packages/nuxt/src/runtime/plugins/storage.server.ts - Runtime instrumentation plugin
  • packages/nuxt/src/vite/storageConfig.ts - Build-time configuration
  • packages/nuxt/src/module.ts - Module integration
  • E2E tests for Nuxt 3 & 4

Copy link

linear bot commented Oct 3, 2025

@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from 07cb542 to 24a5470 Compare October 3, 2025 15:40
@logaretm logaretm linked an issue Oct 3, 2025 that may be closed by this pull request
@logaretm logaretm self-assigned this Oct 4, 2025
@logaretm logaretm marked this pull request as ready for review October 6, 2025 12:28
@logaretm logaretm force-pushed the awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage branch from a6dc41f to fe203a5 Compare October 6, 2025 12:29
cursor[bot]

This comment was marked as outdated.

},
});

addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/storage.server'));
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Plugin Path in Storage Configuration

The addServerPlugin call in storageConfig.ts uses an incorrect relative path to the storage server plugin. Since storageConfig.ts is located in the vite directory, ./runtime/plugins/storage.server resolves to the wrong location, preventing the plugin from being found.

Fix in Cursor Fix in Web

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 a problem, the path isn't relative to current file, but to the module itself.

@logaretm logaretm requested review from s1gr1d and andreiborza October 6, 2025 12:55
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.

[Nuxt/Nitro] Instrument KV Storage (instrumenting unstorage)
1 participant