@@ -261,11 +261,59 @@ static LEAN_COMMITTEE_SIGNATURES_AGGREGATION_TIME_SECONDS: std::sync::LazyLock<H
261261 register_histogram ! (
262262 "lean_committee_signatures_aggregation_time_seconds" ,
263263 "Time taken to aggregate committee signatures" ,
264- vec![ 0.005 , 0.01 , 0.025 , 0.05 , 0.1 , 0.25 , 0.5 , 0.75 , 1 .0]
264+ vec![ 0.05 , 0.1 , 0.25 , 0.5 , 0.75 , 1.0 , 2.0 , 3.0 , 4 .0]
265265 )
266266 . unwrap ( )
267267 } ) ;
268268
269+ static LEAN_BLOCK_AGGREGATED_PAYLOADS : std:: sync:: LazyLock < Histogram > =
270+ std:: sync:: LazyLock :: new ( || {
271+ register_histogram ! (
272+ "lean_block_aggregated_payloads" ,
273+ "Number of aggregated_payloads in a block" ,
274+ vec![ 1.0 , 2.0 , 4.0 , 8.0 , 16.0 , 32.0 , 64.0 , 128.0 ]
275+ )
276+ . unwrap ( )
277+ } ) ;
278+
279+ static LEAN_BLOCK_BUILDING_PAYLOAD_AGGREGATION_TIME_SECONDS : std:: sync:: LazyLock < Histogram > =
280+ std:: sync:: LazyLock :: new ( || {
281+ register_histogram ! (
282+ "lean_block_building_payload_aggregation_time_seconds" ,
283+ "Time taken to build aggregated_payloads during block building" ,
284+ vec![ 0.1 , 0.25 , 0.5 , 0.75 , 1.0 , 2.0 , 3.0 , 4.0 ]
285+ )
286+ . unwrap ( )
287+ } ) ;
288+
289+ static LEAN_BLOCK_BUILDING_TIME_SECONDS : std:: sync:: LazyLock < Histogram > =
290+ std:: sync:: LazyLock :: new ( || {
291+ register_histogram ! (
292+ "lean_block_building_time_seconds" ,
293+ "Time taken to build a block" ,
294+ vec![ 0.01 , 0.025 , 0.05 , 0.1 , 0.25 , 0.5 , 0.75 , 1.0 ]
295+ )
296+ . unwrap ( )
297+ } ) ;
298+
299+ static LEAN_BLOCK_BUILDING_SUCCESS_TOTAL : std:: sync:: LazyLock < IntCounter > =
300+ std:: sync:: LazyLock :: new ( || {
301+ register_int_counter ! (
302+ "lean_block_building_success_total" ,
303+ "Successful block builds"
304+ )
305+ . unwrap ( )
306+ } ) ;
307+
308+ static LEAN_BLOCK_BUILDING_FAILURES_TOTAL : std:: sync:: LazyLock < IntCounter > =
309+ std:: sync:: LazyLock :: new ( || {
310+ register_int_counter ! ( "lean_block_building_failures_total" , "Failed block builds" ) . unwrap ( )
311+ } ) ;
312+
313+ static LEAN_NODE_SYNC_STATUS : std:: sync:: LazyLock < IntGaugeVec > = std:: sync:: LazyLock :: new ( || {
314+ register_int_gauge_vec ! ( "lean_node_sync_status" , "Node sync status" , & [ "status" ] ) . unwrap ( )
315+ } ) ;
316+
269317static LEAN_FORK_CHOICE_REORG_DEPTH : std:: sync:: LazyLock < Histogram > =
270318 std:: sync:: LazyLock :: new ( || {
271319 register_histogram ! (
@@ -314,6 +362,12 @@ pub fn init() {
314362 std:: sync:: LazyLock :: force ( & LEAN_PQ_SIG_AGGREGATED_SIGNATURES_BUILDING_TIME_SECONDS ) ;
315363 std:: sync:: LazyLock :: force ( & LEAN_PQ_SIG_AGGREGATED_SIGNATURES_VERIFICATION_TIME_SECONDS ) ;
316364 std:: sync:: LazyLock :: force ( & LEAN_COMMITTEE_SIGNATURES_AGGREGATION_TIME_SECONDS ) ;
365+ std:: sync:: LazyLock :: force ( & LEAN_BLOCK_AGGREGATED_PAYLOADS ) ;
366+ std:: sync:: LazyLock :: force ( & LEAN_BLOCK_BUILDING_PAYLOAD_AGGREGATION_TIME_SECONDS ) ;
367+ std:: sync:: LazyLock :: force ( & LEAN_BLOCK_BUILDING_TIME_SECONDS ) ;
368+ std:: sync:: LazyLock :: force ( & LEAN_BLOCK_BUILDING_SUCCESS_TOTAL ) ;
369+ std:: sync:: LazyLock :: force ( & LEAN_BLOCK_BUILDING_FAILURES_TOTAL ) ;
370+ std:: sync:: LazyLock :: force ( & LEAN_NODE_SYNC_STATUS ) ;
317371 std:: sync:: LazyLock :: force ( & LEAN_FORK_CHOICE_REORG_DEPTH ) ;
318372}
319373
@@ -476,3 +530,37 @@ pub fn set_attestation_committee_count(count: u64) {
476530pub fn observe_fork_choice_reorg_depth ( depth : u64 ) {
477531 LEAN_FORK_CHOICE_REORG_DEPTH . observe ( depth as f64 ) ;
478532}
533+
534+ /// Observe the number of aggregated payloads in a produced block.
535+ pub fn observe_block_aggregated_payloads ( count : usize ) {
536+ LEAN_BLOCK_AGGREGATED_PAYLOADS . observe ( count as f64 ) ;
537+ }
538+
539+ /// Start timing payload aggregation during block building. Records duration when the guard is dropped.
540+ pub fn time_block_building_payload_aggregation ( ) -> TimingGuard {
541+ TimingGuard :: new ( & LEAN_BLOCK_BUILDING_PAYLOAD_AGGREGATION_TIME_SECONDS )
542+ }
543+
544+ /// Start timing block building. Records duration when the guard is dropped.
545+ pub fn time_block_building ( ) -> TimingGuard {
546+ TimingGuard :: new ( & LEAN_BLOCK_BUILDING_TIME_SECONDS )
547+ }
548+
549+ /// Increment the successful block builds counter.
550+ pub fn inc_block_building_success ( ) {
551+ LEAN_BLOCK_BUILDING_SUCCESS_TOTAL . inc ( ) ;
552+ }
553+
554+ /// Increment the failed block builds counter.
555+ pub fn inc_block_building_failures ( ) {
556+ LEAN_BLOCK_BUILDING_FAILURES_TOTAL . inc ( ) ;
557+ }
558+
559+ /// Set the node sync status. Sets the given status label to 1 and all others to 0.
560+ pub fn set_sync_status ( status : & str ) {
561+ for label in & [ "idle" , "syncing" , "synced" ] {
562+ LEAN_NODE_SYNC_STATUS
563+ . with_label_values ( & [ label] )
564+ . set ( i64:: from ( * label == status) ) ;
565+ }
566+ }
0 commit comments