@@ -8,7 +8,7 @@ use std::{
8
8
pub ( crate ) type DependentTxsVec = SmallVec < [ TxId ; 1 ] > ;
9
9
10
10
use ahash:: { AHashMap as HashMap , AHashSet as HashSet } ;
11
- use metrics:: { counter, histogram} ;
11
+ use metrics:: { counter, gauge , histogram} ;
12
12
13
13
const RAW_TRANSFER_WEIGHT : usize = 1 ;
14
14
@@ -33,6 +33,7 @@ pub(crate) struct TxDependency {
33
33
tx_weight : Option < Vec < usize > > ,
34
34
35
35
pub round : Option < usize > ,
36
+ pub block_height : u64 ,
36
37
}
37
38
38
39
impl TxDependency {
@@ -43,6 +44,7 @@ impl TxDependency {
43
44
tx_running_time : None ,
44
45
tx_weight : None ,
45
46
round : None ,
47
+ block_height : 0 ,
46
48
}
47
49
}
48
50
@@ -210,6 +212,25 @@ impl TxDependency {
210
212
self . num_finality_txs = num_finality_txs;
211
213
}
212
214
215
+ fn draw_dependent_graph ( & self ) {
216
+ let num_finality_txs = self . num_finality_txs ;
217
+ for ( index, dep) in self . tx_dependency . iter ( ) . enumerate ( ) {
218
+ let txid = index + num_finality_txs;
219
+ let round = self . round . map ( |r| format ! ( "round{}" , r) ) . unwrap_or ( String :: from ( "none" ) ) ;
220
+ gauge ! ( "node_status" ,
221
+ "id" => format!( "tx{}" , txid) , "status" => "healthy" ,
222
+ "round" => round. clone( ) , "block_height" => format!( "{}" , self . block_height) )
223
+ . set ( 1.0 ) ;
224
+ let dep: BTreeSet < TxId > = dep. clone ( ) . into_iter ( ) . collect ( ) ;
225
+ for dep_id in dep {
226
+ gauge ! ( "edge_flow" ,
227
+ "source" => format!( "tx{}" , txid) , "target" => format!( "tx{}" , dep_id) ,
228
+ "round" => round. clone( ) , "block_height" => format!( "{}" , self . block_height) )
229
+ . set ( 1.0 ) ;
230
+ }
231
+ }
232
+ }
233
+
213
234
fn skew_analyze ( & self , weighted_group : & BTreeMap < usize , Vec < DependentTxsVec > > ) {
214
235
if !( * DEBUG_BOTTLENECK ) {
215
236
return ;
@@ -236,6 +257,7 @@ impl TxDependency {
236
257
if num_txs < 64 || num_remaining < num_txs / 3 || subgraph. is_empty ( ) {
237
258
return ;
238
259
}
260
+ self . draw_dependent_graph ( ) ;
239
261
240
262
// ChainLength -> ChainNumber
241
263
let mut chains = BTreeMap :: new ( ) ;
0 commit comments