sui_core/checkpoints/checkpoint_executor/
metrics.rs1use mysten_metrics::histogram::Histogram as MystenHistogram;
5use prometheus::{
6 Histogram, IntCounter, IntCounterVec, IntGauge, Registry, register_histogram_with_registry,
7 register_int_counter_vec_with_registry, register_int_counter_with_registry,
8 register_int_gauge_with_registry,
9};
10use std::sync::Arc;
11
12pub struct CheckpointExecutorMetrics {
13 pub checkpoint_exec_sync_tps: IntGauge,
14 pub last_executed_checkpoint: IntGauge,
15 pub last_executed_checkpoint_timestamp_ms: IntGauge,
16 pub checkpoint_exec_errors: IntCounter,
17 pub checkpoint_exec_epoch: IntGauge,
18 pub checkpoint_exec_inflight: IntGauge,
19 pub checkpoint_exec_latency: Histogram,
20 pub checkpoint_prepare_latency: Histogram,
21 pub checkpoint_transaction_count: Histogram,
22 pub checkpoint_contents_age: Histogram,
23 pub checkpoint_contents_age_ms: MystenHistogram,
25 pub last_executed_checkpoint_age: Histogram,
26 pub last_executed_checkpoint_age_ms: MystenHistogram,
28 pub checkpoint_executor_validator_path: IntGauge,
29 pub checkpoint_executor_validator_sync_fallback_path: IntGauge,
30
31 pub stage_wait_duration_ns: IntCounterVec,
32 pub stage_active_duration_ns: IntCounterVec,
33}
34
35impl CheckpointExecutorMetrics {
36 pub fn new(registry: &Registry) -> Arc<Self> {
37 let this = Self {
38 checkpoint_exec_sync_tps: register_int_gauge_with_registry!(
39 "checkpoint_exec_sync_tps",
40 "Checkpoint sync estimated transactions per second",
41 registry
42 )
43 .unwrap(),
44 last_executed_checkpoint: register_int_gauge_with_registry!(
45 "last_executed_checkpoint",
46 "Last executed checkpoint",
47 registry
48 )
49 .unwrap(),
50 last_executed_checkpoint_timestamp_ms: register_int_gauge_with_registry!(
51 "last_executed_checkpoint_timestamp_ms",
52 "Last executed checkpoint timestamp ms",
53 registry
54 )
55 .unwrap(),
56 checkpoint_exec_errors: register_int_counter_with_registry!(
57 "checkpoint_exec_errors",
58 "Checkpoint execution errors count",
59 registry
60 )
61 .unwrap(),
62 checkpoint_exec_epoch: register_int_gauge_with_registry!(
63 "checkpoint_exec_epoch",
64 "Current epoch number in the checkpoint executor",
65 registry
66 )
67 .unwrap(),
68 checkpoint_exec_inflight: register_int_gauge_with_registry!(
69 "checkpoint_exec_inflight",
70 "Current number of inflight checkpoints being executed",
71 registry
72 )
73 .unwrap(),
74 checkpoint_exec_latency: register_histogram_with_registry!(
75 "checkpoint_exec_latency",
76 "Latency of executing a checkpoint from enqueue to all effects available",
77 mysten_metrics::SUBSECOND_LATENCY_SEC_BUCKETS.to_vec(),
78 registry,
79 )
80 .unwrap(),
81 checkpoint_prepare_latency: register_histogram_with_registry!(
82 "checkpoint_prepare_latency",
83 "Latency of preparing a checkpoint to enqueue for execution",
84 mysten_metrics::SUBSECOND_LATENCY_SEC_BUCKETS.to_vec(),
85 registry,
86 )
87 .unwrap(),
88 checkpoint_transaction_count: register_histogram_with_registry!(
89 "checkpoint_transaction_count",
90 "Number of transactions in the checkpoint",
91 mysten_metrics::COUNT_BUCKETS.to_vec(),
92 registry,
93 )
94 .unwrap(),
95 checkpoint_contents_age: register_histogram_with_registry!(
96 "checkpoint_contents_age",
97 "Age of checkpoints when they arrive for execution",
98 mysten_metrics::LATENCY_SEC_BUCKETS.to_vec(),
99 registry,
100 )
101 .unwrap(),
102 checkpoint_contents_age_ms: MystenHistogram::new_in_registry(
103 "checkpoint_contents_age_ms",
104 "Age of checkpoints when they arrive for execution",
105 registry,
106 ),
107 last_executed_checkpoint_age: register_histogram_with_registry!(
108 "last_executed_checkpoint_age",
109 "Age of the last executed checkpoint",
110 mysten_metrics::LATENCY_SEC_BUCKETS.to_vec(),
111 registry
112 )
113 .unwrap(),
114 last_executed_checkpoint_age_ms: MystenHistogram::new_in_registry(
115 "last_executed_checkpoint_age_ms",
116 "Age of the last executed checkpoint",
117 registry,
118 ),
119 checkpoint_executor_validator_path: register_int_gauge_with_registry!(
120 "checkpoint_executor_validator_path",
121 "Number of checkpoints executed using the validator path",
122 registry
123 )
124 .unwrap(),
125 checkpoint_executor_validator_sync_fallback_path: register_int_gauge_with_registry!(
126 "checkpoint_executor_validator_sync_fallback_path",
127 "Number of checkpoints executed using the validator fallback path to synced checkpoints",
128 registry
129 )
130 .unwrap(),
131 stage_wait_duration_ns: register_int_counter_vec_with_registry!(
132 "checkpoint_executor_pipeline_stage_wait_duration_ns",
133 "Pipeline stage wait duration in nanoseconds",
134 &["stage"],
135 registry,
136 )
137 .unwrap(),
138 stage_active_duration_ns: register_int_counter_vec_with_registry!(
139 "checkpoint_executor_pipeline_stage_active_duration_ns",
140 "Pipeline stage active duration in nanoseconds",
141 &["stage"],
142 registry,
143 )
144 .unwrap(),
145 };
146 Arc::new(this)
147 }
148
149 pub fn new_for_tests() -> Arc<Self> {
150 Self::new(&Registry::new())
151 }
152}