Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions crates/apollo_integration_tests/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use apollo_integration_tests::utils::{
CreateRpcTxsFn,
TestTxHashesFn,
};
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusRecorder};
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use pretty_assertions::assert_eq;
use starknet_api::execution_resources::GasAmount;
use starknet_api::transaction::TransactionHash;
Expand All @@ -38,8 +38,9 @@ pub async fn end_to_end_flow(
configure_tracing().await;

let mut tx_generator = create_flow_test_tx_generator();
let recorder = PrometheusBuilder::new().build_recorder();
let _recorder_guard = metrics::set_default_local_recorder(&recorder);
let global_recorder_handle = PrometheusBuilder::new()
.install_recorder()
.expect("Should be able to install global prometheus recorder");

const TEST_SCENARIO_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(50);
// Setup.
Expand Down Expand Up @@ -106,7 +107,7 @@ pub async fn end_to_end_flow(
{current_batched_txs_count}"
);

current_batched_txs_count = get_total_batched_txs_count(&recorder);
current_batched_txs_count = get_total_batched_txs_count(&global_recorder_handle);
if current_batched_txs_count == total_expected_batched_txs_count {
break;
}
Expand All @@ -124,7 +125,7 @@ pub async fn end_to_end_flow(
});
}

assert_full_blocks_flow(&recorder, expecting_full_blocks);
assert_full_blocks_flow(&global_recorder_handle, expecting_full_blocks);
}

pub struct TestScenario {
Expand All @@ -133,13 +134,13 @@ pub struct TestScenario {
pub test_tx_hashes_fn: TestTxHashesFn,
}

fn get_total_batched_txs_count(recorder: &PrometheusRecorder) -> usize {
let metrics = recorder.handle().render();
fn get_total_batched_txs_count(handle: &PrometheusHandle) -> usize {
let metrics = handle.render();
apollo_batcher::metrics::BATCHED_TRANSACTIONS.parse_numeric_metric::<usize>(&metrics).unwrap()
}

fn assert_full_blocks_flow(recorder: &PrometheusRecorder, expecting_full_blocks: bool) {
let metrics = recorder.handle().render();
fn assert_full_blocks_flow(recorder_handle: &PrometheusHandle, expecting_full_blocks: bool) {
let metrics = recorder_handle.render();
let full_blocks_metric = apollo_batcher::metrics::BLOCK_CLOSE_REASON
.parse_numeric_metric::<u64>(
&metrics,
Expand Down
Loading