@@ -70,6 +70,7 @@ pub struct KeeperMetrics {
70
70
pub collected_fee : Family < AccountLabel , Gauge < f64 , AtomicU64 > > ,
71
71
pub current_fee : Family < AccountLabel , Gauge < f64 , AtomicU64 > > ,
72
72
pub total_gas_spent : Family < AccountLabel , Gauge < f64 , AtomicU64 > > ,
73
+ pub total_gas_fee_spent : Family < AccountLabel , Gauge < f64 , AtomicU64 > > ,
73
74
pub requests : Family < AccountLabel , Counter > ,
74
75
pub requests_processed : Family < AccountLabel , Counter > ,
75
76
pub requests_processed_success : Family < AccountLabel , Counter > ,
@@ -88,6 +89,7 @@ impl Default for KeeperMetrics {
88
89
collected_fee : Family :: default ( ) ,
89
90
current_fee : Family :: default ( ) ,
90
91
total_gas_spent : Family :: default ( ) ,
92
+ total_gas_fee_spent : Family :: default ( ) ,
91
93
requests : Family :: default ( ) ,
92
94
requests_processed : Family :: default ( ) ,
93
95
requests_processed_success : Family :: default ( ) ,
@@ -178,6 +180,12 @@ impl KeeperMetrics {
178
180
keeper_metrics. total_gas_spent . clone ( ) ,
179
181
) ;
180
182
183
+ writable_registry. register (
184
+ "total_gas_fee_spent" ,
185
+ "Total amount of ETH spent on gas for revealing requests" ,
186
+ keeper_metrics. total_gas_fee_spent . clone ( ) ,
187
+ ) ;
188
+
181
189
writable_registry. register (
182
190
"requests_reprocessed" ,
183
191
"Number of requests reprocessed" ,
@@ -476,6 +484,7 @@ pub async fn process_event_with_backoff(
476
484
. contract
477
485
. get_request ( event. provider_address , event. sequence_number )
478
486
. await ;
487
+
479
488
tracing:: error!( "Failed to process event: {:?}. Request: {:?}" , e, req) ;
480
489
481
490
// We only count failures for cases where we are completely certain that the callback failed.
@@ -635,30 +644,28 @@ pub async fn process_event(
635
644
receipt
636
645
) ;
637
646
647
+ let account_label = AccountLabel {
648
+ chain_id : chain_config. id . clone ( ) ,
649
+ address : chain_config. provider_address . to_string ( ) ,
650
+ } ;
651
+
638
652
if let Some ( gas_used) = receipt. gas_used {
639
- let gas_used = gas_used. as_u128 ( ) as f64 / 1e18 ;
653
+ let gas_used_float = gas_used. as_u128 ( ) as f64 / 1e18 ;
640
654
metrics
641
655
. total_gas_spent
642
- . get_or_create ( & AccountLabel {
643
- chain_id : chain_config. id . clone ( ) ,
644
- address : client
645
- . inner ( )
646
- . inner ( )
647
- . inner ( )
648
- . signer ( )
649
- . address ( )
650
- . to_string ( ) ,
651
- } )
652
- . inc_by ( gas_used) ;
656
+ . get_or_create ( & account_label)
657
+ . inc_by ( gas_used_float) ;
658
+
659
+ if let Some ( gas_price) = receipt. effective_gas_price {
660
+ let gas_fee = ( gas_used * gas_price) . as_u128 ( ) as f64 / 1e18 ;
661
+ metrics
662
+ . total_gas_fee_spent
663
+ . get_or_create ( & account_label)
664
+ . inc_by ( gas_fee) ;
665
+ }
653
666
}
654
667
655
- metrics
656
- . reveals
657
- . get_or_create ( & AccountLabel {
658
- chain_id : chain_config. id . clone ( ) ,
659
- address : chain_config. provider_address . to_string ( ) ,
660
- } )
661
- . inc ( ) ;
668
+ metrics. reveals . get_or_create ( & account_label) . inc ( ) ;
662
669
663
670
Ok ( ( ) )
664
671
}
0 commit comments