mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Publish EL Info in Metrics (#7052)
Since we now know the EL version, we should publish this to our metrics periodically.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1554,10 +1554,14 @@ impl<E: EthSpec> ExecutionLayer<E> {
|
||||
&self,
|
||||
age_limit: Option<Duration>,
|
||||
) -> Result<Vec<ClientVersionV1>, Error> {
|
||||
self.engine()
|
||||
let versions = self
|
||||
.engine()
|
||||
.request(|engine| engine.get_engine_version(age_limit))
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
.map_err(Into::<Error>::into)?;
|
||||
metrics::expose_execution_layer_info(&versions);
|
||||
|
||||
Ok(versions)
|
||||
}
|
||||
|
||||
/// Used during block production to determine if the merge has been triggered.
|
||||
|
||||
@@ -116,3 +116,29 @@ pub static EXECUTION_LAYER_PAYLOAD_BIDS: LazyLock<Result<IntGaugeVec>> = LazyLoc
|
||||
&["source"]
|
||||
)
|
||||
});
|
||||
pub static EXECUTION_LAYER_INFO: LazyLock<Result<IntGaugeVec>> = 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<crate::ClientVersionV1>) {
|
||||
for el in els {
|
||||
set_gauge_vec(
|
||||
&EXECUTION_LAYER_INFO,
|
||||
&[
|
||||
&el.code.to_string(),
|
||||
&el.name,
|
||||
&el.version,
|
||||
&el.commit.to_string(),
|
||||
],
|
||||
1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user