@@ -20,7 +20,7 @@ use apollo_integration_tests::utils::{
20
20
CreateRpcTxsFn ,
21
21
TestTxHashesFn ,
22
22
} ;
23
- use metrics_exporter_prometheus:: { PrometheusBuilder , PrometheusRecorder } ;
23
+ use metrics_exporter_prometheus:: { PrometheusBuilder , PrometheusHandle } ;
24
24
use pretty_assertions:: assert_eq;
25
25
use starknet_api:: execution_resources:: GasAmount ;
26
26
use starknet_api:: transaction:: TransactionHash ;
@@ -39,8 +39,9 @@ pub async fn end_to_end_flow(
39
39
configure_tracing ( ) . await ;
40
40
41
41
let mut tx_generator = create_flow_test_tx_generator ( ) ;
42
- let recorder = PrometheusBuilder :: new ( ) . build_recorder ( ) ;
43
- let _recorder_guard = metrics:: set_default_local_recorder ( & recorder) ;
42
+ let global_recorder_handle = PrometheusBuilder :: new ( )
43
+ . install_recorder ( )
44
+ . expect ( "Should be able to install global prometheus recorder" ) ;
44
45
45
46
const TEST_SCENARIO_TIMEOUT : std:: time:: Duration = std:: time:: Duration :: from_secs ( 50 ) ;
46
47
// Setup.
@@ -107,7 +108,7 @@ pub async fn end_to_end_flow(
107
108
{current_batched_txs_count}"
108
109
) ;
109
110
110
- current_batched_txs_count = get_total_batched_txs_count ( & recorder ) ;
111
+ current_batched_txs_count = get_total_batched_txs_count ( & global_recorder_handle ) ;
111
112
if current_batched_txs_count == total_expected_batched_txs_count {
112
113
break ;
113
114
}
@@ -125,8 +126,8 @@ pub async fn end_to_end_flow(
125
126
} ) ;
126
127
}
127
128
128
- assert_full_blocks_flow ( & recorder , expecting_full_blocks) ;
129
- assert_no_reverted_transactions_flow ( & recorder ) ;
129
+ assert_full_blocks_flow ( & global_recorder_handle , expecting_full_blocks) ;
130
+ assert_no_reverted_transactions_flow ( & global_recorder_handle ) ;
130
131
}
131
132
132
133
pub struct TestScenario {
@@ -135,13 +136,13 @@ pub struct TestScenario {
135
136
pub test_tx_hashes_fn : TestTxHashesFn ,
136
137
}
137
138
138
- fn get_total_batched_txs_count ( recorder : & PrometheusRecorder ) -> usize {
139
- let metrics = recorder . handle ( ) . render ( ) ;
139
+ fn get_total_batched_txs_count ( handle : & PrometheusHandle ) -> usize {
140
+ let metrics = handle. render ( ) ;
140
141
apollo_batcher:: metrics:: BATCHED_TRANSACTIONS . parse_numeric_metric :: < usize > ( & metrics) . unwrap ( )
141
142
}
142
143
143
- fn assert_full_blocks_flow ( recorder : & PrometheusRecorder , expecting_full_blocks : bool ) {
144
- let metrics = recorder . handle ( ) . render ( ) ;
144
+ fn assert_full_blocks_flow ( recorder_handle : & PrometheusHandle , expecting_full_blocks : bool ) {
145
+ let metrics = recorder_handle . render ( ) ;
145
146
let full_blocks_metric = apollo_batcher:: metrics:: BLOCK_CLOSE_REASON
146
147
. parse_numeric_metric :: < u64 > (
147
148
& metrics,
@@ -158,8 +159,8 @@ fn assert_full_blocks_flow(recorder: &PrometheusRecorder, expecting_full_blocks:
158
159
}
159
160
}
160
161
161
- fn assert_no_reverted_transactions_flow ( recorder : & PrometheusRecorder ) {
162
- let metrics = recorder . handle ( ) . render ( ) ;
162
+ fn assert_no_reverted_transactions_flow ( recorder_handle : & PrometheusHandle ) {
163
+ let metrics = recorder_handle . render ( ) ;
163
164
let reverted_transactions_metric =
164
165
REVERTED_TRANSACTIONS . parse_numeric_metric :: < u64 > ( & metrics) . unwrap ( ) ;
165
166
assert_eq ! ( reverted_transactions_metric, 0 ) ;
0 commit comments