@@ -71,10 +71,15 @@ pub struct TelemetryState {
71
71
/// The balance in each wallet that Hermes is using, per wallet, denom and chain
72
72
wallet_balance : ValueRecorder < u64 > ,
73
73
74
+ /// Indicates the latency for all transactions submitted to a specific chain,
75
+ /// i.e. the difference between the moment when Hermes received a batch of events
76
+ /// until the corresponding transaction(s) were submitted. Milliseconds.
77
+ tx_latency_submitted : ValueRecorder < u64 > ,
78
+
74
79
/// Indicates the latency for all transactions submitted to a specific chain,
75
80
/// i.e. the difference between the moment when Hermes received a batch of events
76
81
/// until the corresponding transaction(s) were confirmed. Milliseconds.
77
- tx_latency : ValueRecorder < u64 > ,
82
+ tx_latency_confirmed : ValueRecorder < u64 > ,
78
83
79
84
/// Records the time at which we started processing an event batch.
80
85
/// Used for computing the `tx_latency` metric.
@@ -216,12 +221,27 @@ impl TelemetryState {
216
221
self . wallet_balance . record ( amount, labels) ;
217
222
}
218
223
219
- pub fn start_process_batch ( & self , tracking_id : impl ToString ) {
224
+ pub fn received_event_batch ( & self , tracking_id : impl ToString ) {
220
225
self . in_flight_events
221
226
. insert ( tracking_id. to_string ( ) , Instant :: now ( ) ) ;
222
227
}
223
228
224
- pub fn end_process_batch ( & self , chain_id : & ChainId , tracking_id : impl ToString ) {
229
+ pub fn tx_submitted ( & self , chain_id : & ChainId , tracking_id : impl ToString ) {
230
+ let tracking_id = tracking_id. to_string ( ) ;
231
+
232
+ if let Some ( start) = self . in_flight_events . get ( & tracking_id) {
233
+ let latency = start. elapsed ( ) . as_millis ( ) as u64 ;
234
+
235
+ let labels = & [
236
+ KeyValue :: new ( "chain" , chain_id. to_string ( ) ) ,
237
+ KeyValue :: new ( "tracking_id" , tracking_id) ,
238
+ ] ;
239
+
240
+ self . tx_latency_submitted . record ( latency, labels) ;
241
+ }
242
+ }
243
+
244
+ pub fn tx_confirmed ( & self , chain_id : & ChainId , tracking_id : impl ToString ) {
225
245
let tracking_id = tracking_id. to_string ( ) ;
226
246
227
247
if let Some ( start) = self . in_flight_events . get ( & tracking_id) {
@@ -232,7 +252,7 @@ impl TelemetryState {
232
252
KeyValue :: new ( "tracking_id" , tracking_id) ,
233
253
] ;
234
254
235
- self . tx_latency . record ( latency, labels) ;
255
+ self . tx_latency_confirmed . record ( latency, labels) ;
236
256
}
237
257
}
238
258
}
@@ -307,8 +327,15 @@ impl Default for TelemetryState {
307
327
. with_description ( "The balance in each wallet that Hermes is using, per wallet, denom and chain" )
308
328
. init ( ) ,
309
329
310
- tx_latency : meter
311
- . u64_value_recorder ( "tx_latency" )
330
+ tx_latency_submitted : meter
331
+ . u64_value_recorder ( "tx_latency_submitted" )
332
+ . with_description ( "The latency for all transactions submitted to a specific chain, \
333
+ i.e. the difference between the moment when Hermes received a batch of events \
334
+ and when it submitted the corresponding transaction(s). Milliseconds.")
335
+ . init ( ) ,
336
+
337
+ tx_latency_confirmed : meter
338
+ . u64_value_recorder ( "tx_latency_confirmed" )
312
339
. with_description ( "The latency for all transactions submitted to a specific chain, \
313
340
i.e. the difference between the moment when Hermes received a batch of events \
314
341
until the corresponding transaction(s) were confirmed. Milliseconds.")
0 commit comments