From bae5dd496cb2252bdc69c85cb86f00cc3d915149 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 4 Dec 2025 21:46:09 +0100 Subject: [PATCH] DAL node: add a metric counting unattested slots seen --- src/lib_dal_node/dal_metrics.ml | 13 +++++++++++++ src/lib_dal_node/dal_metrics.mli | 3 +++ src/lib_dal_node/store.ml | 7 ++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lib_dal_node/dal_metrics.ml b/src/lib_dal_node/dal_metrics.ml index cfe7e5f90cb8..3ae0d0827748 100644 --- a/src/lib_dal_node/dal_metrics.ml +++ b/src/lib_dal_node/dal_metrics.ml @@ -93,6 +93,16 @@ module Node_metrics = struct ~subsystem name + let slots_unattested = + let name = "slots_unattested" in + Prometheus.Counter.v_label + ~label_name:"slot_index" + ~help: + "Count of published but unattested slot at index since node started" + ~namespace + ~subsystem + name + let attested_slots_for_baker_per_level_ratio = let name = "attested_slot_for_baker_per_level_ratio" in Prometheus.Gauge.v_label @@ -616,6 +626,9 @@ let slot_attested ~set i = let v = float_of_int @@ if set then 1 else 0 in Prometheus.Gauge.set (Node_metrics.slots_attested (string_of_int i)) v +let slot_unattested i = + Prometheus.Counter.inc_one (Node_metrics.slots_unattested (string_of_int i)) + let attested_slots_for_baker_per_level_ratio ~delegate ratio = let attester = Format.asprintf "%a@." Signature.Public_key_hash.pp delegate in Prometheus.Gauge.set diff --git a/src/lib_dal_node/dal_metrics.mli b/src/lib_dal_node/dal_metrics.mli index 04dc4535884c..928297c48d02 100644 --- a/src/lib_dal_node/dal_metrics.mli +++ b/src/lib_dal_node/dal_metrics.mli @@ -33,6 +33,9 @@ val slot_waiting_for_attestation : set:bool -> int -> unit value is set to 1 if [set] is true, and -1 otherwise. *) val slot_attested : set:bool -> int -> unit +(** Increment the count of unattested slots. *) +val slot_unattested : int -> unit + (** Update the "attestation" ratio for the baker *) val attested_slots_for_baker_per_level_ratio : delegate:Signature.Public_key_hash.t -> float -> unit diff --git a/src/lib_dal_node/store.ml b/src/lib_dal_node/store.ml index adcb2996fb73..f633af84c031 100644 --- a/src/lib_dal_node/store.ml +++ b/src/lib_dal_node/store.ml @@ -682,9 +682,14 @@ module Statuses_cache = struct | Some `Unattested -> assert false) ; match status with | `Attested _lag -> Dal_metrics.slot_attested ~set:true slot_id.slot_index - | `Unattested | `Unpublished | `Waiting_attestation -> + | `Unattested -> + (* per the invariant stated above, the function can only be called once + per slot_id with the `Unattested value *) + Dal_metrics.slot_unattested slot_id.slot_index ; (* TODO: is the right way to update the metric here?? *) Dal_metrics.slot_attested ~set:false slot_id.slot_index + | `Unpublished | `Waiting_attestation -> + Dal_metrics.slot_attested ~set:false slot_id.slot_index end module Commitment_indexed_cache = -- GitLab