@@ -40,7 +40,7 @@ const KEYED_METHODS = new Set<DriverMethod>([
40
40
/**
41
41
* Methods that should have a attribute to indicate a cache hit.
42
42
*/
43
- const CACHE_HIT_METHODS = new Set < DriverMethod > ( [ 'hasItem' , 'getItem' , 'getItemRaw' , 'getKeys' ] ) ;
43
+ const CACHE_HIT_METHODS = new Set < DriverMethod > ( [ 'hasItem' , 'getItem' , 'getItemRaw' ] ) ;
44
44
45
45
/**
46
46
* Creates a Nitro plugin that instruments the storage driver.
@@ -66,10 +66,10 @@ export default defineNitroPlugin(async _nitroApp => {
66
66
} catch {
67
67
debug . error ( `[storage] Failed to unmount mount: "${ mount . base } "` ) ;
68
68
}
69
-
70
- // Wrap the mount method to instrument future mounts
71
- storage . mount = wrapStorageMount ( storage ) ;
72
69
}
70
+
71
+ // Wrap the mount method to instrument future mounts
72
+ storage . mount = wrapStorageMount ( storage ) ;
73
73
} ) ;
74
74
75
75
/**
@@ -147,7 +147,7 @@ function createMethodWrapper(
147
147
span . setStatus ( { code : SPAN_STATUS_OK } ) ;
148
148
149
149
if ( CACHE_HIT_METHODS . has ( methodName ) ) {
150
- span . setAttribute ( SEMANTIC_ATTRIBUTE_CACHE_HIT , true ) ;
150
+ span . setAttribute ( SEMANTIC_ATTRIBUTE_CACHE_HIT , ! isEmptyValue ( result ) ) ;
151
151
}
152
152
153
153
return result ;
@@ -214,3 +214,10 @@ function getSpanAttributes(methodName: string, driver: Driver, mountBase: string
214
214
function normalizeMethodName ( methodName : string ) : string {
215
215
return methodName . replace ( / [ A - Z ] / g, letter => `_${ letter . toLowerCase ( ) } ` ) ;
216
216
}
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