Skip to content

Commit

Permalink
add RELAY_LAST_SLOT metric
Browse files Browse the repository at this point in the history
  • Loading branch information
ltitanb committed Sep 16, 2024
1 parent 8ec2a4e commit 991859c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 11 additions & 2 deletions crates/pbs/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use lazy_static::lazy_static;
use prometheus::{
register_histogram_vec_with_registry, register_int_counter_vec_with_registry, HistogramVec,
IntCounterVec, Registry,
register_histogram_vec_with_registry, register_int_counter_vec_with_registry,
register_int_gauge_vec_with_registry, HistogramVec, IntCounterVec, IntGaugeVec, Registry,
};

lazy_static! {
Expand All @@ -32,6 +32,15 @@ lazy_static! {
)
.unwrap();

/// Latest slot for which relay delivered a header
pub static ref RELAY_LAST_SLOT: IntGaugeVec = register_int_gauge_vec_with_registry!(
"relay_last_slot",
"Latest slot for which relay delivered a header",
&["relay_id"],
PBS_METRICS_REGISTRY
)
.unwrap();

// TO BEACON NODE
/// Status code returned to beacon node by endpoint
pub static ref BEACON_NODE_STATUS: IntCounterVec = register_int_counter_vec_with_registry!(
Expand Down
7 changes: 5 additions & 2 deletions crates/pbs/src/mev_boost/get_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use url::Url;

use crate::{
constants::{GET_HEADER_ENDPOINT_TAG, TIMEOUT_ERROR_CODE, TIMEOUT_ERROR_CODE_STR},
metrics::{RELAY_LATENCY, RELAY_STATUS_CODE},
metrics::{RELAY_LAST_SLOT, RELAY_LATENCY, RELAY_STATUS_CODE},
state::{BuilderApiState, PbsState},
};

Expand Down Expand Up @@ -79,7 +79,10 @@ pub async fn get_header<S: BuilderApiState>(
let relay_id = relays[i].id.as_ref();

match res {
Ok(Some(res)) => relay_bids.push(res),
Ok(Some(res)) => {
RELAY_LAST_SLOT.with_label_values(&[relay_id]).set(params.slot as i64);
relay_bids.push(res)
}
Ok(_) => {}
Err(err) if err.is_timeout() => error!(err = "Timed Out", relay_id),
Err(err) => error!(?err, relay_id),
Expand Down

0 comments on commit 991859c

Please sign in to comment.