Skip to content

Commit 3e78034

Browse files
authored
Add BEACON_PROCESSOR_WORKERS_ACTIVE_GAUGE_BY_TYPE metric (#7935)
Similar to `BEACON_PROCESSOR_WORKERS_ACTIVE_TOTAL` but this metric also records the work type. This is useful in identifying the task when a worker is stuck due to a deadlock or something else, and usually difficult to debug in production / release mode.
1 parent 78b4cca commit 3e78034

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

beacon_node/beacon_processor/src/lib.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
14031403
}
14041404
};
14051405

1406-
metrics::set_gauge(
1407-
&metrics::BEACON_PROCESSOR_WORKERS_ACTIVE_TOTAL,
1408-
self.current_workers as i64,
1409-
);
1410-
14111406
if let Some(modified_queue_id) = modified_queue_id {
14121407
let queue_len = match modified_queue_id {
14131408
WorkType::GossipAttestation => attestation_queue.len(),
@@ -1520,6 +1515,11 @@ impl<E: EthSpec> BeaconProcessor<E> {
15201515
&[work.str_id()],
15211516
);
15221517

1518+
metrics::inc_gauge_vec(
1519+
&metrics::BEACON_PROCESSOR_WORKERS_ACTIVE_GAUGE_BY_TYPE,
1520+
&[work_id],
1521+
);
1522+
15231523
// Wrap the `idle_tx` in a struct that will fire the idle message whenever it is dropped.
15241524
//
15251525
// This helps ensure that the worker is always freed in the case of an early exit or panic.
@@ -1688,6 +1688,11 @@ pub struct SendOnDrop {
16881688

16891689
impl Drop for SendOnDrop {
16901690
fn drop(&mut self) {
1691+
metrics::dec_gauge_vec(
1692+
&metrics::BEACON_PROCESSOR_WORKERS_ACTIVE_GAUGE_BY_TYPE,
1693+
&[self.work_type.clone().into()],
1694+
);
1695+
16911696
if let Err(e) = self.tx.try_send(self.work_type.clone()) {
16921697
warn!(
16931698
msg = "did not free worker, shutdown may be underway",

beacon_node/beacon_processor/src/metrics.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ pub static BEACON_PROCESSOR_WORKERS_SPAWNED_TOTAL: LazyLock<Result<IntCounter>>
4242
"The number of workers ever spawned by the gossip processing pool.",
4343
)
4444
});
45-
pub static BEACON_PROCESSOR_WORKERS_ACTIVE_TOTAL: LazyLock<Result<IntGauge>> =
45+
pub static BEACON_PROCESSOR_WORKERS_ACTIVE_GAUGE_BY_TYPE: LazyLock<Result<IntGaugeVec>> =
4646
LazyLock::new(|| {
47-
try_create_int_gauge(
48-
"beacon_processor_workers_active_total",
49-
"Count of active workers in the gossip processing pool.",
47+
try_create_int_gauge_vec(
48+
"beacon_processor_workers_active_gauge_by_type",
49+
"Int gauge of the number of active workers per work type",
50+
&["type"],
5051
)
5152
});
5253
pub static BEACON_PROCESSOR_IDLE_EVENTS_TOTAL: LazyLock<Result<IntCounter>> = LazyLock::new(|| {

0 commit comments

Comments
 (0)