From 0ae64dcb791d80cc9a512c2f6d87ef186a270542 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Fri, 13 Mar 2026 17:36:14 -0300 Subject: [PATCH 1/3] Add lean_attestation_committee_count Prometheus metric Expose the attestation committee count as a Prometheus gauge on node start, matching the leanMetrics spec. The value comes from the existing --attestation-committee-count CLI option. --- bin/ethlambda/src/main.rs | 3 +++ crates/blockchain/src/metrics.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/bin/ethlambda/src/main.rs b/bin/ethlambda/src/main.rs index 40ed12c..5ec59d1 100644 --- a/bin/ethlambda/src/main.rs +++ b/bin/ethlambda/src/main.rs @@ -82,6 +82,9 @@ async fn main() -> eyre::Result<()> { // Set node info metrics ethlambda_blockchain::metrics::set_node_info("ethlambda", version::CLIENT_VERSION); ethlambda_blockchain::metrics::set_node_start_time(); + ethlambda_blockchain::metrics::set_attestation_committee_count( + options.attestation_committee_count, + ); let metrics_socket = SocketAddr::new(options.metrics_address, options.metrics_port); let node_p2p_key = read_hex_file_bytes(&options.node_key); diff --git a/crates/blockchain/src/metrics.rs b/crates/blockchain/src/metrics.rs index c44d369..5370f88 100644 --- a/crates/blockchain/src/metrics.rs +++ b/crates/blockchain/src/metrics.rs @@ -358,6 +358,19 @@ pub fn set_is_aggregator(is_aggregator: bool) { LEAN_IS_AGGREGATOR.set(i64::from(is_aggregator)); } +/// Set the attestation committee count gauge. +pub fn set_attestation_committee_count(count: u64) { + static LEAN_ATTESTATION_COMMITTEE_COUNT: std::sync::LazyLock = + std::sync::LazyLock::new(|| { + register_int_gauge!( + "lean_attestation_committee_count", + "Number of attestation committees (ATTESTATION_COMMITTEE_COUNT)" + ) + .unwrap() + }); + LEAN_ATTESTATION_COMMITTEE_COUNT.set(count as i64); +} + /// Observe the depth of a fork choice reorg. pub fn observe_fork_choice_reorg_depth(depth: u64) { static LEAN_FORK_CHOICE_REORG_DEPTH: std::sync::LazyLock = From f357438834358c522102293ec98869e0aa4028f9 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Fri, 13 Mar 2026 18:42:13 -0300 Subject: [PATCH 2/3] Add lean_attestation_committee_count to docs/metrics.md and fix cast style - Document the new metric in the Network Metrics table - Use try_into().unwrap() instead of `as i64` for consistency with other u64-to-i64 conversions in the file --- crates/blockchain/src/metrics.rs | 2 +- docs/metrics.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/blockchain/src/metrics.rs b/crates/blockchain/src/metrics.rs index 5370f88..b6d5920 100644 --- a/crates/blockchain/src/metrics.rs +++ b/crates/blockchain/src/metrics.rs @@ -368,7 +368,7 @@ pub fn set_attestation_committee_count(count: u64) { ) .unwrap() }); - LEAN_ATTESTATION_COMMITTEE_COUNT.set(count as i64); + LEAN_ATTESTATION_COMMITTEE_COUNT.set(count.try_into().unwrap()); } /// Observe the depth of a fork choice reorg. diff --git a/docs/metrics.md b/docs/metrics.md index b562782..7e167e9 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -73,6 +73,7 @@ The exposed metrics follow [the leanMetrics specification](https://github.com/le | Name | Type | Usage | Sample collection event | Labels | Supported | |--------|-------|-------|-------------------------|--------|-----------| +|`lean_attestation_committee_count`| Gauge | Number of attestation committees | On node start | | ✅ | |`lean_connected_peers`| Gauge | Number of connected peers | On scrape | client=ethlambda,grandine,lantern,lighthouse,qlean,ream,zeam | ✅(*) | |`lean_peer_connection_events_total`| Counter | Total number of peer connection events | On peer connection | direction=inbound,outbound
result=success,timeout,error | ✅ | |`lean_peer_disconnection_events_total`| Counter | Total number of peer disconnection events | On peer disconnection | direction=inbound,outbound
reason=timeout,remote_close,local_close,error | ✅ | From 8f065b7bf97f43c05aa2b53ebc21b57322b43a95 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Fri, 13 Mar 2026 18:42:42 -0300 Subject: [PATCH 3/3] Revert try_into().unwrap() cast, keep as i64 for metrics setter A panic in a metrics setter is worse than a theoretical silent wrap on a value that will never exceed i64::MAX in practice. --- crates/blockchain/src/metrics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/blockchain/src/metrics.rs b/crates/blockchain/src/metrics.rs index b6d5920..88c5817 100644 --- a/crates/blockchain/src/metrics.rs +++ b/crates/blockchain/src/metrics.rs @@ -368,7 +368,7 @@ pub fn set_attestation_committee_count(count: u64) { ) .unwrap() }); - LEAN_ATTESTATION_COMMITTEE_COUNT.set(count.try_into().unwrap()); + LEAN_ATTESTATION_COMMITTEE_COUNT.set(count.try_into().unwrap_or_default()); } /// Observe the depth of a fork choice reorg.