@@ -40,7 +40,7 @@ const KEYED_METHODS = new Set<DriverMethod>([
4040/**
4141 * Methods that should have a attribute to indicate a cache hit.
4242 */
43- const CACHE_HIT_METHODS = new Set < DriverMethod > ( [ 'hasItem' , 'getItem' , 'getItemRaw' , 'getKeys' ] ) ;
43+ const CACHE_HIT_METHODS = new Set < DriverMethod > ( [ 'hasItem' , 'getItem' , 'getItemRaw' ] ) ;
4444
4545/**
4646 * Creates a Nitro plugin that instruments the storage driver.
@@ -66,10 +66,10 @@ export default defineNitroPlugin(async _nitroApp => {
6666 } catch {
6767 debug . error ( `[storage] Failed to unmount mount: "${ mount . base } "` ) ;
6868 }
69-
70- // Wrap the mount method to instrument future mounts
71- storage . mount = wrapStorageMount ( storage ) ;
7269 }
70+
71+ // Wrap the mount method to instrument future mounts
72+ storage . mount = wrapStorageMount ( storage ) ;
7373} ) ;
7474
7575/**
@@ -147,7 +147,7 @@ function createMethodWrapper(
147147 span . setStatus ( { code : SPAN_STATUS_OK } ) ;
148148
149149 if ( CACHE_HIT_METHODS . has ( methodName ) ) {
150- span . setAttribute ( SEMANTIC_ATTRIBUTE_CACHE_HIT , true ) ;
150+ span . setAttribute ( SEMANTIC_ATTRIBUTE_CACHE_HIT , ! isEmptyValue ( result ) ) ;
151151 }
152152
153153 return result ;
@@ -214,3 +214,10 @@ function getSpanAttributes(methodName: string, driver: Driver, mountBase: string
214214function normalizeMethodName ( methodName : string ) : string {
215215 return methodName . replace ( / [ A - Z ] / g, letter => `_${ letter . toLowerCase ( ) } ` ) ;
216216}
217+
218+ /**
219+ * Checks if the value is empty, used for cache hit detection.
220+ */
221+ function isEmptyValue ( value : unknown ) : boolean {
222+ return value === null || value === undefined ;
223+ }
0 commit comments