Line data Source code
1 : use metrics::{register_int_counter, register_int_counter_vec, IntCounter, IntCounterVec};
2 : use once_cell::sync::Lazy;
3 :
4 : pub(crate) struct ReconcilerMetrics {
5 : pub(crate) spawned: IntCounter,
6 : pub(crate) complete: IntCounterVec,
7 : }
8 :
9 : impl ReconcilerMetrics {
10 : // Labels used on [`Self::complete`]
11 : pub(crate) const SUCCESS: &'static str = "ok";
12 : pub(crate) const ERROR: &'static str = "success";
13 : pub(crate) const CANCEL: &'static str = "cancel";
14 : }
15 :
16 0 : pub(crate) static RECONCILER: Lazy<ReconcilerMetrics> = Lazy::new(|| ReconcilerMetrics {
17 0 : spawned: register_int_counter!(
18 0 : "storage_controller_reconcile_spawn",
19 0 : "Count of how many times we spawn a reconcile task",
20 0 : )
21 0 : .expect("failed to define a metric"),
22 0 : complete: register_int_counter_vec!(
23 0 : "storage_controller_reconcile_complete",
24 0 : "Reconciler tasks completed, broken down by success/failure/cancelled",
25 0 : &["status"],
26 0 : )
27 0 : .expect("failed to define a metric"),
28 0 : });
29 :
30 0 : pub fn preinitialize_metrics() {
31 0 : Lazy::force(&RECONCILER);
32 0 : }
|