@@ -6,6 +6,7 @@ use std::sync::Arc;
66pub struct PaymentsPollerMetrics {
77 pub registry : Registry ,
88 pub last_processed_block : Gauge ,
9+ pub active_subscriptions : Gauge ,
910}
1011
1112impl PaymentsPollerMetrics {
@@ -17,14 +18,21 @@ impl PaymentsPollerMetrics {
1718 "Last processed block by poller"
1819 ) ) ?;
1920
21+ let active_subscriptions = Gauge :: with_opts ( opts ! (
22+ "active_subscriptions" ,
23+ "Active payment subscriptions by poller"
24+ ) ) ?;
25+
2026 registry. register ( Box :: new ( last_processed_block. clone ( ) ) ) ?;
27+ registry. register ( Box :: new ( active_subscriptions. clone ( ) ) ) ?;
2128
2229 // Arc is used because metrics are a shared resource accessed by both the background and metrics HTTP
2330 // server and the application code, across multiple Actix worker threads. The server outlives start(),
2431 // so the data must be static and safely shared between threads.
2532 let metrics = Arc :: new ( Self {
2633 registry,
2734 last_processed_block,
35+ active_subscriptions,
2836 } ) ;
2937
3038 let server_metrics = metrics. clone ( ) ;
@@ -63,4 +71,8 @@ impl PaymentsPollerMetrics {
6371 pub fn register_last_processed_block ( & self , value : u64 ) {
6472 self . last_processed_block . set ( value as f64 ) ;
6573 }
74+
75+ pub fn register_active_subscriptions ( & self , value : i64 ) {
76+ self . active_subscriptions . set ( value as f64 ) ;
77+ }
6678}
0 commit comments