@@ -6,6 +6,7 @@ use prometheus::{IntGauge, Opts, Registry};
66pub struct Metrics {
77 pub rpc_requests : Arc < IntGauge > ,
88 pub blocks_added : Arc < IntGauge > ,
9+ pub failed_rpc_requests : Arc < IntGauge > ,
910 pub registry : Arc < Registry > ,
1011}
1112
@@ -21,17 +22,26 @@ impl Metrics {
2122 "The number of blocks added to the index" ,
2223 ) )
2324 . expect ( "Invalid blocks_added gauge definition" ) ;
25+ let failed_rpc_requests = IntGauge :: with_opts ( Opts :: new (
26+ "failed_rpc_requests" ,
27+ "The number of requests made to the RPC node that have received an error response" ,
28+ ) )
29+ . expect ( "Invalid rpc_requests gauge definition" ) ;
2430 let registry = Registry :: new ( ) ;
2531 registry
2632 . register ( Box :: new ( rpc_requests. clone ( ) ) )
2733 . expect ( "Invalid metrics registry definition" ) ;
2834 registry
2935 . register ( Box :: new ( blocks_added. clone ( ) ) )
3036 . expect ( "Invalid metrics registry definition" ) ;
37+ registry
38+ . register ( Box :: new ( failed_rpc_requests. clone ( ) ) )
39+ . expect ( "Invalid metrics registry definition" ) ;
3140
3241 Self {
3342 rpc_requests : Arc :: new ( rpc_requests) ,
3443 blocks_added : Arc :: new ( blocks_added) ,
44+ failed_rpc_requests : Arc :: new ( failed_rpc_requests) ,
3545 registry : Arc :: new ( registry) ,
3646 }
3747 }
0 commit comments