@@ -20,6 +20,8 @@ pub struct BatcherMetrics {
2020 pub batcher_started : IntCounter ,
2121 pub gas_price_used_on_latest_batch : IntGauge ,
2222 pub broken_ws_connections : IntCounter ,
23+ pub queue_len : IntGauge ,
24+ pub queue_size_bytes : IntGauge ,
2325 pub s3_duration : IntGauge ,
2426 pub create_new_task_duration : IntGauge ,
2527 pub cancel_create_new_task_duration : IntGauge ,
@@ -52,6 +54,11 @@ impl BatcherMetrics {
5254 "broken_ws_connections_count" ,
5355 "Broken websocket connections"
5456 ) ) ?;
57+ let queue_len = register_int_gauge ! ( opts!( "queue_len" , "Amount of proofs in the queue" ) ) ?;
58+ let queue_size_bytes = register_int_gauge ! ( opts!(
59+ "queue_size_bytes" ,
60+ "Accumulated size in bytes of all proofs in the queue"
61+ ) ) ?;
5562 let s3_duration = register_int_gauge ! ( opts!( "s3_duration" , "S3 Duration" ) ) ?;
5663 let create_new_task_duration = register_int_gauge ! ( opts!(
5764 "create_new_task_duration" ,
@@ -82,6 +89,8 @@ impl BatcherMetrics {
8289 registry. register ( Box :: new ( gas_price_used_on_latest_batch. clone ( ) ) ) ?;
8390 registry. register ( Box :: new ( batcher_started. clone ( ) ) ) ?;
8491 registry. register ( Box :: new ( broken_ws_connections. clone ( ) ) ) ?;
92+ registry. register ( Box :: new ( queue_len. clone ( ) ) ) ?;
93+ registry. register ( Box :: new ( queue_size_bytes. clone ( ) ) ) ?;
8594 registry. register ( Box :: new ( s3_duration. clone ( ) ) ) ?;
8695 registry. register ( Box :: new ( create_new_task_duration. clone ( ) ) ) ?;
8796 registry. register ( Box :: new ( cancel_create_new_task_duration. clone ( ) ) ) ?;
@@ -108,6 +117,8 @@ impl BatcherMetrics {
108117 batcher_started,
109118 gas_price_used_on_latest_batch,
110119 broken_ws_connections,
120+ queue_len,
121+ queue_size_bytes,
111122 s3_duration,
112123 create_new_task_duration,
113124 cancel_create_new_task_duration,
@@ -142,4 +153,9 @@ impl BatcherMetrics {
142153 pub fn user_error ( & self , label_values : & [ & str ] ) {
143154 self . user_errors . with_label_values ( label_values) . inc ( ) ;
144155 }
156+
157+ pub fn update_queue_metrics ( & self , queue_len : i64 , queue_size : i64 ) {
158+ self . queue_len . set ( queue_len) ;
159+ self . queue_size_bytes . set ( queue_size) ;
160+ }
145161}
0 commit comments