Skip to content

Commit 6af8c18

Browse files
authored
Publish EL Info in Metrics (#7052)
Since we now know the EL version, we should publish this to our metrics periodically.
1 parent ce8d081 commit 6af8c18

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

beacon_node/execution_layer/src/engine_api/http.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,10 @@ impl HttpJsonRpc {
12421242
} else {
12431243
let engine_version = self.get_client_version_v1().await?;
12441244
*lock = Some(CachedResponse::new(engine_version.clone()));
1245+
if !engine_version.is_empty() {
1246+
// reset metric gauge when there's a fresh fetch
1247+
crate::metrics::reset_execution_layer_info_gauge();
1248+
}
12451249
Ok(engine_version)
12461250
}
12471251
}

beacon_node/execution_layer/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,10 +1554,14 @@ impl<E: EthSpec> ExecutionLayer<E> {
15541554
&self,
15551555
age_limit: Option<Duration>,
15561556
) -> Result<Vec<ClientVersionV1>, Error> {
1557-
self.engine()
1557+
let versions = self
1558+
.engine()
15581559
.request(|engine| engine.get_engine_version(age_limit))
15591560
.await
1560-
.map_err(Into::into)
1561+
.map_err(Into::<Error>::into)?;
1562+
metrics::expose_execution_layer_info(&versions);
1563+
1564+
Ok(versions)
15611565
}
15621566

15631567
/// Used during block production to determine if the merge has been triggered.

beacon_node/execution_layer/src/metrics.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,29 @@ pub static EXECUTION_LAYER_PAYLOAD_BIDS: LazyLock<Result<IntGaugeVec>> = LazyLoc
116116
&["source"]
117117
)
118118
});
119+
pub static EXECUTION_LAYER_INFO: LazyLock<Result<IntGaugeVec>> = LazyLock::new(|| {
120+
try_create_int_gauge_vec(
121+
"execution_layer_info",
122+
"The build of the execution layer connected to lighthouse",
123+
&["code", "name", "version", "commit"],
124+
)
125+
});
126+
127+
pub fn reset_execution_layer_info_gauge() {
128+
let _ = EXECUTION_LAYER_INFO.as_ref().map(|gauge| gauge.reset());
129+
}
130+
131+
pub fn expose_execution_layer_info(els: &Vec<crate::ClientVersionV1>) {
132+
for el in els {
133+
set_gauge_vec(
134+
&EXECUTION_LAYER_INFO,
135+
&[
136+
&el.code.to_string(),
137+
&el.name,
138+
&el.version,
139+
&el.commit.to_string(),
140+
],
141+
1,
142+
);
143+
}
144+
}

0 commit comments

Comments
 (0)