@@ -3,7 +3,7 @@ use metrics::{
3
3
register_counter_vec, register_gauge_vec, register_histogram, register_histogram_vec,
4
4
register_int_counter, register_int_counter_pair_vec, register_int_counter_vec,
5
5
register_int_gauge, register_int_gauge_vec, register_uint_gauge, register_uint_gauge_vec,
6
- Counter , CounterVec , GaugeVec , Histogram , HistogramVec , IntCounter , IntCounterPair ,
6
+ Counter , CounterVec , Gauge , GaugeVec , Histogram , HistogramVec , IntCounter , IntCounterPair ,
7
7
IntCounterPairVec , IntCounterVec , IntGauge , IntGaugeVec , UIntGauge , UIntGaugeVec ,
8
8
} ;
9
9
use once_cell:: sync:: Lazy ;
@@ -457,6 +457,15 @@ pub(crate) static WAIT_LSN_TIME: Lazy<Histogram> = Lazy::new(|| {
457
457
. expect ( "failed to define a metric" )
458
458
} ) ;
459
459
460
+ static FLUSH_WAIT_UPLOAD_TIME : Lazy < GaugeVec > = Lazy :: new ( || {
461
+ register_gauge_vec ! (
462
+ "pageserver_flush_wait_upload_seconds" ,
463
+ "Time spent waiting for preceding uploads during layer flush" ,
464
+ & [ "tenant_id" , "shard_id" , "timeline_id" ]
465
+ )
466
+ . expect ( "failed to define a metric" )
467
+ } ) ;
468
+
460
469
static LAST_RECORD_LSN : Lazy < IntGaugeVec > = Lazy :: new ( || {
461
470
register_int_gauge_vec ! (
462
471
"pageserver_last_record_lsn" ,
@@ -2336,6 +2345,7 @@ pub(crate) struct TimelineMetrics {
2336
2345
shard_id : String ,
2337
2346
timeline_id : String ,
2338
2347
pub flush_time_histo : StorageTimeMetrics ,
2348
+ pub flush_wait_upload_time_gauge : Gauge ,
2339
2349
pub compact_time_histo : StorageTimeMetrics ,
2340
2350
pub create_images_time_histo : StorageTimeMetrics ,
2341
2351
pub logical_size_histo : StorageTimeMetrics ,
@@ -2379,6 +2389,9 @@ impl TimelineMetrics {
2379
2389
& shard_id,
2380
2390
& timeline_id,
2381
2391
) ;
2392
+ let flush_wait_upload_time_gauge = FLUSH_WAIT_UPLOAD_TIME
2393
+ . get_metric_with_label_values ( & [ & tenant_id, & shard_id, & timeline_id] )
2394
+ . unwrap ( ) ;
2382
2395
let compact_time_histo = StorageTimeMetrics :: new (
2383
2396
StorageTimeOperation :: Compact ,
2384
2397
& tenant_id,
@@ -2516,6 +2529,7 @@ impl TimelineMetrics {
2516
2529
shard_id,
2517
2530
timeline_id,
2518
2531
flush_time_histo,
2532
+ flush_wait_upload_time_gauge,
2519
2533
compact_time_histo,
2520
2534
create_images_time_histo,
2521
2535
logical_size_histo,
@@ -2563,6 +2577,14 @@ impl TimelineMetrics {
2563
2577
self . resident_physical_size_gauge . get ( )
2564
2578
}
2565
2579
2580
+ pub ( crate ) fn flush_wait_upload_time_gauge_add ( & self , duration : f64 ) {
2581
+ self . flush_wait_upload_time_gauge . add ( duration) ;
2582
+ crate :: metrics:: FLUSH_WAIT_UPLOAD_TIME
2583
+ . get_metric_with_label_values ( & [ & self . tenant_id , & self . shard_id , & self . timeline_id ] )
2584
+ . unwrap ( )
2585
+ . add ( duration) ;
2586
+ }
2587
+
2566
2588
pub ( crate ) fn shutdown ( & self ) {
2567
2589
let was_shutdown = self
2568
2590
. shutdown
@@ -2579,6 +2601,7 @@ impl TimelineMetrics {
2579
2601
let timeline_id = & self . timeline_id ;
2580
2602
let shard_id = & self . shard_id ;
2581
2603
let _ = LAST_RECORD_LSN . remove_label_values ( & [ tenant_id, shard_id, timeline_id] ) ;
2604
+ let _ = FLUSH_WAIT_UPLOAD_TIME . remove_label_values ( & [ tenant_id, shard_id, timeline_id] ) ;
2582
2605
let _ = STANDBY_HORIZON . remove_label_values ( & [ tenant_id, shard_id, timeline_id] ) ;
2583
2606
{
2584
2607
RESIDENT_PHYSICAL_SIZE_GLOBAL . sub ( self . resident_physical_size_get ( ) ) ;
0 commit comments