14
14
// You should have received a copy of the GNU General Public License
15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
+ use stacks_common:: define_named_enum;
18
+
17
19
#[ cfg( feature = "monitoring_prom" ) ]
18
20
mod prometheus;
19
21
20
22
#[ cfg( feature = "monitoring_prom" ) ]
21
23
mod server;
22
24
25
+ define_named_enum ! (
26
+ /// Represent different state change reason on signer agreement protocol
27
+ SignerAgreementStateChangeReason {
28
+ /// A new burn block has arrived
29
+ BurnBlockArrival ( "burn_block_arrival" ) ,
30
+ /// A new stacks block has arrived
31
+ StacksBlockArrival ( "stacks_block_arrival" ) ,
32
+ /// A miner is inactive when it should be starting its tenure
33
+ InactiveMiner ( "inactive_miner" ) ,
34
+ /// Signer agreement protocol version has been upgraded
35
+ ProtocolUpgrade ( "protocol_upgrade" ) ,
36
+ } ) ;
37
+
23
38
/// Actions for updating metrics
24
39
#[ cfg( feature = "monitoring_prom" ) ]
25
40
pub mod actions {
@@ -29,6 +44,7 @@ pub mod actions {
29
44
30
45
use crate :: config:: GlobalConfig ;
31
46
use crate :: monitoring:: prometheus:: * ;
47
+ use crate :: monitoring:: SignerAgreementStateChangeReason ;
32
48
use crate :: v0:: signer_state:: LocalStateMachine ;
33
49
34
50
/// Update stacks tip height gauge
@@ -108,6 +124,16 @@ pub mod actions {
108
124
. replace ( state) ;
109
125
}
110
126
127
+ /// Increment signer agreement state change reason counter
128
+ pub fn increment_signer_agreement_state_change_reason (
129
+ reason : SignerAgreementStateChangeReason ,
130
+ ) {
131
+ let label_value = reason. get_name ( ) ;
132
+ SIGNER_AGREEMENT_STATE_CHANGE_REASONS
133
+ . with_label_values ( & [ & label_value] )
134
+ . inc ( ) ;
135
+ }
136
+
111
137
/// Start serving monitoring metrics.
112
138
/// This will only serve the metrics if the `monitoring_prom` feature is enabled.
113
139
pub fn start_serving_monitoring_metrics ( config : GlobalConfig ) -> Result < ( ) , String > {
@@ -131,6 +157,7 @@ pub mod actions {
131
157
use blockstack_lib:: chainstate:: nakamoto:: NakamotoBlock ;
132
158
use stacks_common:: info;
133
159
160
+ use crate :: monitoring:: SignerAgreementStateChangeReason ;
134
161
use crate :: v0:: signer_state:: LocalStateMachine ;
135
162
use crate :: GlobalConfig ;
136
163
@@ -179,6 +206,12 @@ pub mod actions {
179
206
/// Record the current local state machine
180
207
pub fn record_local_state ( _state : LocalStateMachine ) { }
181
208
209
+ /// Increment signer agreement state change reason counter
210
+ pub fn increment_signer_agreement_state_change_reason (
211
+ _reason : SignerAgreementStateChangeReason ,
212
+ ) {
213
+ }
214
+
182
215
/// Start serving monitoring metrics.
183
216
/// This will only serve the metrics if the `monitoring_prom` feature is enabled.
184
217
pub fn start_serving_monitoring_metrics ( config : GlobalConfig ) -> Result < ( ) , String > {
0 commit comments