@@ -20,6 +20,33 @@ mod prometheus;
20
20
#[ cfg( feature = "monitoring_prom" ) ]
21
21
mod server;
22
22
23
+ /// Represent different state change reason on signer agreement protocol
24
+ pub enum SignerAgreementStateChangeReason {
25
+ /// A new burn block has arrived
26
+ BurnBlockArrival ,
27
+ /// A new stacks block has arrived
28
+ StacksBlockArrival ,
29
+ /// A miner is inactive when it should be starting its tenure
30
+ InactiveMiner ,
31
+ /// Signer agreement protocol version has been upgraded
32
+ ProtocalUpgrade ,
33
+ }
34
+
35
+ impl std:: fmt:: Display for SignerAgreementStateChangeReason {
36
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
37
+ write ! (
38
+ f,
39
+ "{}" ,
40
+ match self {
41
+ SignerAgreementStateChangeReason :: BurnBlockArrival => "burn_block_arrival" ,
42
+ SignerAgreementStateChangeReason :: StacksBlockArrival => "stacks_block_arrival" ,
43
+ SignerAgreementStateChangeReason :: InactiveMiner => "inactive_miner" ,
44
+ SignerAgreementStateChangeReason :: ProtocalUpgrade => "protocol_upgrade" ,
45
+ }
46
+ )
47
+ }
48
+ }
49
+
23
50
/// Actions for updating metrics
24
51
#[ cfg( feature = "monitoring_prom" ) ]
25
52
pub mod actions {
@@ -29,6 +56,7 @@ pub mod actions {
29
56
30
57
use crate :: config:: GlobalConfig ;
31
58
use crate :: monitoring:: prometheus:: * ;
59
+ use crate :: monitoring:: SignerAgreementStateChangeReason ;
32
60
use crate :: v0:: signer_state:: LocalStateMachine ;
33
61
34
62
/// Update stacks tip height gauge
@@ -108,6 +136,16 @@ pub mod actions {
108
136
. replace ( state) ;
109
137
}
110
138
139
+ /// Increment signer agreement state change reason counter
140
+ pub fn increment_signer_agreement_state_change_reason (
141
+ reason : SignerAgreementStateChangeReason ,
142
+ ) {
143
+ let label_value = reason. to_string ( ) ;
144
+ SIGNER_AGREEMENT_STATE_CHANGE_REASONS
145
+ . with_label_values ( & [ & label_value] )
146
+ . inc ( ) ;
147
+ }
148
+
111
149
/// Start serving monitoring metrics.
112
150
/// This will only serve the metrics if the `monitoring_prom` feature is enabled.
113
151
pub fn start_serving_monitoring_metrics ( config : GlobalConfig ) -> Result < ( ) , String > {
@@ -131,6 +169,7 @@ pub mod actions {
131
169
use blockstack_lib:: chainstate:: nakamoto:: NakamotoBlock ;
132
170
use stacks_common:: info;
133
171
172
+ use crate :: monitoring:: SignerAgreementStateChangeReason ;
134
173
use crate :: v0:: signer_state:: LocalStateMachine ;
135
174
use crate :: GlobalConfig ;
136
175
@@ -179,6 +218,12 @@ pub mod actions {
179
218
/// Record the current local state machine
180
219
pub fn record_local_state ( _state : LocalStateMachine ) { }
181
220
221
+ /// Increment signer agreement state change reason counter
222
+ pub fn increment_signer_agreement_state_change_reason (
223
+ _reason : SignerAgreementStateChangeReason ,
224
+ ) {
225
+ }
226
+
182
227
/// Start serving monitoring metrics.
183
228
/// This will only serve the metrics if the `monitoring_prom` feature is enabled.
184
229
pub fn start_serving_monitoring_metrics ( config : GlobalConfig ) -> Result < ( ) , String > {
0 commit comments