From 6af8c187e0b7d441553588ae79c80d54d1fcc8d7 Mon Sep 17 00:00:00 2001 From: ethDreamer <37123614+ethDreamer@users.noreply.github.com> Date: Wed, 21 May 2025 21:51:30 -0500 Subject: [PATCH] Publish EL Info in Metrics (#7052) Since we now know the EL version, we should publish this to our metrics periodically. --- .../execution_layer/src/engine_api/http.rs | 4 +++ beacon_node/execution_layer/src/lib.rs | 8 ++++-- beacon_node/execution_layer/src/metrics.rs | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index bf4c391a8d..c79036ba61 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -1242,6 +1242,10 @@ impl HttpJsonRpc { } else { let engine_version = self.get_client_version_v1().await?; *lock = Some(CachedResponse::new(engine_version.clone())); + if !engine_version.is_empty() { + // reset metric gauge when there's a fresh fetch + crate::metrics::reset_execution_layer_info_gauge(); + } Ok(engine_version) } } diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 248bca6826..4761c47d41 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -1554,10 +1554,14 @@ impl ExecutionLayer { &self, age_limit: Option, ) -> Result, Error> { - self.engine() + let versions = self + .engine() .request(|engine| engine.get_engine_version(age_limit)) .await - .map_err(Into::into) + .map_err(Into::::into)?; + metrics::expose_execution_layer_info(&versions); + + Ok(versions) } /// Used during block production to determine if the merge has been triggered. diff --git a/beacon_node/execution_layer/src/metrics.rs b/beacon_node/execution_layer/src/metrics.rs index ab1a22677f..aba8434c8e 100644 --- a/beacon_node/execution_layer/src/metrics.rs +++ b/beacon_node/execution_layer/src/metrics.rs @@ -116,3 +116,29 @@ pub static EXECUTION_LAYER_PAYLOAD_BIDS: LazyLock> = LazyLoc &["source"] ) }); +pub static EXECUTION_LAYER_INFO: LazyLock> = LazyLock::new(|| { + try_create_int_gauge_vec( + "execution_layer_info", + "The build of the execution layer connected to lighthouse", + &["code", "name", "version", "commit"], + ) +}); + +pub fn reset_execution_layer_info_gauge() { + let _ = EXECUTION_LAYER_INFO.as_ref().map(|gauge| gauge.reset()); +} + +pub fn expose_execution_layer_info(els: &Vec) { + for el in els { + set_gauge_vec( + &EXECUTION_LAYER_INFO, + &[ + &el.code.to_string(), + &el.name, + &el.version, + &el.commit.to_string(), + ], + 1, + ); + } +}