@@ -7,6 +7,11 @@ use mountpoint_s3_fs::S3FilesystemConfig;
77use mountpoint_s3_fs:: data_cache:: {
88 DiskDataCache , DiskDataCacheConfig , ExpressDataCache , ExpressDataCacheConfig , MultilevelDataCache ,
99} ;
10+ use mountpoint_s3_fs:: metrics:: defs:: {
11+ ATTR_CACHE , CACHE_DISK , CACHE_EVICT_LATENCY , CACHE_EXPRESS , CACHE_GET_IO_SIZE , CACHE_GET_LATENCY ,
12+ CACHE_PUT_IO_SIZE , CACHE_PUT_LATENCY ,
13+ } ;
14+
1015use mountpoint_s3_fs:: metrics:: defs:: {
1116 ATTR_FUSE_REQUEST , FUSE_IO_SIZE , FUSE_REQUEST_ERRORS , FUSE_REQUEST_LATENCY , PREFETCH_RESET_STATE ,
1217} ;
@@ -239,23 +244,22 @@ rusty_fork_test! {
239244 test_session. client( ) . put_object( "file.txt" , & content) . unwrap( ) ;
240245 let path = test_session. mount_path( ) . join( "file.txt" ) ;
241246
242- // First read - populate cache and wait for asynchronous cache updates
247+ // First read - populate cache
243248 File :: open( & path) . unwrap( ) . read_to_end( & mut Vec :: new( ) ) . unwrap( ) ;
244249 sleep( Duration :: from_millis( 100 ) ) ;
245250
246251 // No cache hits but cache should be updated
247252 assert!( recorder. get( "fuse.cache_hit" , & [ ] ) . is_none( ) , "Cache hit metric should not exist after cache miss" ) ;
248- assert_metric_exists( & recorder, "disk_data_cache.write_duration_us" , & [ ] ) ;
249- assert_metric_exists( & recorder, "disk_data_cache.total_bytes" , & [ ( "type" , "write" ) ] ) ;
253+ assert_metric_exists( & recorder, CACHE_PUT_LATENCY , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
254+ assert_metric_exists( & recorder, CACHE_PUT_IO_SIZE , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
250255
251256 // Second read - cache hit
252257 File :: open( & path) . unwrap( ) . read_to_end( & mut Vec :: new( ) ) . unwrap( ) ;
253258
254259 // Verify cache hit metrics
255260 assert_metric_exists( & recorder, "fuse.cache_hit" , & [ ] ) ;
256- assert_metric_exists( & recorder, "disk_data_cache.block_hit" , & [ ] ) ;
257- assert_metric_exists( & recorder, "disk_data_cache.read_duration_us" , & [ ] ) ;
258- assert_metric_exists( & recorder, "disk_data_cache.total_bytes" , & [ ( "type" , "read" ) ] ) ;
261+ assert_metric_exists( & recorder, CACHE_GET_LATENCY , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
262+ assert_metric_exists( & recorder, CACHE_GET_IO_SIZE , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
259263
260264 // Read a large file to trigger eviction metrics
261265 let large_content = vec![ b'z' ; 2 * 1024 * 1024 ] ;
@@ -265,7 +269,7 @@ rusty_fork_test! {
265269 sleep( Duration :: from_millis( 100 ) ) ;
266270
267271 // Verify eviction metrics
268- assert_metric_exists( & recorder, "disk_data_cache.eviction_duration_us" , & [ ] ) ;
272+ assert_metric_exists( & recorder, CACHE_EVICT_LATENCY , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
269273 }
270274
271275 #[ test]
@@ -304,22 +308,21 @@ rusty_fork_test! {
304308 sleep( Duration :: from_millis( 100 ) ) ;
305309
306310 // Verify cache population metrics
307- // Currently, disk_data_cache.read_duration_us is only recorded on cache hits, not misses.
308311 // But they are recorded for express.
309312 assert!( recorder. get( "fuse.cache_hit" , & [ ] ) . is_none( ) , "Cache hit metric should not exist after cache miss" ) ;
310- assert_metric_exists( & recorder, "disk_data_cache.write_duration_us" , & [ ] ) ;
311- assert_metric_exists( & recorder, "disk_data_cache.total_bytes" , & [ ( "type" , "write" ) ] ) ;
312- assert_metric_exists( & recorder, "express_data_cache.write_duration_us" , & [ ( "type" , "ok" ) ] ) ;
313- assert_metric_exists( & recorder, "express_data_cache.total_bytes" , & [ ( "type" , "write" ) ] ) ;
314- assert_metric_exists( & recorder, "express_data_cache.read_duration_us" , & [ ( "type" , "miss" ) ] ) ;
313+ assert_metric_exists( & recorder, CACHE_PUT_LATENCY , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
314+ assert_metric_exists( & recorder, CACHE_PUT_IO_SIZE , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
315+ assert_metric_exists( & recorder, CACHE_GET_LATENCY , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
316+ assert_metric_exists( & recorder, CACHE_PUT_LATENCY , & [ ( ATTR_CACHE , CACHE_EXPRESS ) ] ) ;
317+ assert_metric_exists( & recorder, CACHE_PUT_IO_SIZE , & [ ( ATTR_CACHE , CACHE_EXPRESS ) ] ) ;
318+ assert_metric_exists( & recorder, CACHE_GET_LATENCY , & [ ( ATTR_CACHE , CACHE_EXPRESS ) ] ) ;
315319
316320 // Second read should hit disk cache after async write completes
317321 File :: open( & path) . unwrap( ) . read_to_end( & mut Vec :: new( ) ) . unwrap( ) ;
318322 sleep( Duration :: from_millis( 100 ) ) ;
319323
320324 assert_metric_exists( & recorder, "fuse.cache_hit" , & [ ] ) ;
321- assert_metric_exists( & recorder, "disk_data_cache.block_hit" , & [ ] ) ;
322- assert_metric_exists( & recorder, "disk_data_cache.read_duration_us" , & [ ] ) ;
323- assert_metric_exists( & recorder, "disk_data_cache.total_bytes" , & [ ( "type" , "read" ) ] ) ;
325+ assert_metric_exists( & recorder, CACHE_GET_LATENCY , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
326+ assert_metric_exists( & recorder, CACHE_GET_IO_SIZE , & [ ( ATTR_CACHE , CACHE_DISK ) ] ) ;
324327 }
325328}
0 commit comments