21
21
} ,
22
22
p2w_sdk:: P2WEmitter ,
23
23
prometheus:: {
24
+ register_histogram,
24
25
register_int_counter,
25
26
register_int_gauge,
27
+ Histogram ,
26
28
IntCounter ,
27
29
IntGauge ,
28
30
} ,
@@ -99,6 +101,13 @@ lazy_static! {
99
101
"Latest sequence number produced by this attester"
100
102
)
101
103
. expect( "FATAL: Could not instantiate LAST_SEQNO_GAUGE" ) ;
104
+ static ref SOL_RPC_TX_PROCESSING_HIST : Histogram = register_histogram!(
105
+ "sol_rpc_tx_processing" ,
106
+ "How long in milliseconds it takes to send a transaction to the Solana RPC" ,
107
+ prometheus:: exponential_buckets( 0.016 , 2.0 , 13 ) // 0.016s, 0.032s, 0.064s, [...], 65.536s
108
+ . expect( "FATAL: Could not instantiate buckets for SOL_RPC_TX_PROCESSING_HIST" )
109
+ )
110
+ . expect( "FATAL: Could not instantiate SOL_RPC_TX_PROCESSING_HIST" ) ;
102
111
}
103
112
104
113
#[ tokio:: main( flavor = "multi_thread" ) ]
@@ -813,6 +822,9 @@ async fn attestation_job(args: AttestationJobArgs) -> Result<(), ErrBoxSend> {
813
822
symbols. as_slice ( ) ,
814
823
latest_blockhash,
815
824
) ;
825
+
826
+ let tx_processing_start_time = Instant :: now ( ) ;
827
+
816
828
let sig = rpc
817
829
. send_and_confirm_transaction ( & tx_res?)
818
830
. map_err ( |e| -> ErrBoxSend { e. into ( ) } )
@@ -827,6 +839,15 @@ async fn attestation_job(args: AttestationJobArgs) -> Result<(), ErrBoxSend> {
827
839
} ,
828
840
)
829
841
. await ?;
842
+
843
+ let tx_processing_duration = tx_processing_start_time. elapsed ( ) ;
844
+
845
+ // Manually insert the value into histogram. NOTE: We're not
846
+ // using the start_timer() method because it would record
847
+ // durations even for early returns in error conditions which
848
+ // would look weird in monitoring.
849
+ SOL_RPC_TX_PROCESSING_HIST . observe ( tx_processing_duration. as_secs_f64 ( ) ) ;
850
+
830
851
let seqno = tx_data
831
852
. transaction
832
853
. meta
0 commit comments