Skip to content

Commit

Permalink
feat(starknet_sequencer_metrics): add infra metric counters and adjus…
Browse files Browse the repository at this point in the history
…t macros to create hash maps

commit-id:34419b89
  • Loading branch information
lev-starkware committed Feb 13, 2025
1 parent 302ac43 commit 6985e91
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/starknet_sequencer_metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true

[dependencies]
clap.workspace = true
lazy_static.workspace = true
metrics.workspace = true
num-traits.workspace = true
regex.workspace = true
Expand Down
46 changes: 46 additions & 0 deletions crates/starknet_sequencer_metrics/src/metric_definitions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use std::collections::HashMap;

use lazy_static::lazy_static;

use crate::metrics::{MetricCounter, MetricGauge, MetricScope};

#[cfg(test)]
Expand Down Expand Up @@ -36,6 +40,18 @@ macro_rules! define_counter_metrics {
$($name),*
),*
];

lazy_static! {
pub static ref METRIC_COUNTERS_MAP: HashMap<&'static str, &'static MetricCounter> = {
let mut map = HashMap::new();
$(
$(
map.insert($key, &$name);
)*
)*
map
};
}
};
}

Expand Down Expand Up @@ -70,6 +86,18 @@ macro_rules! define_gauge_metrics {
$($name),*
),*
];

lazy_static! {
pub static ref METRIC_GAUGES_MAP: HashMap<&'static str, &'static MetricGauge> = {
let mut map = HashMap::new();
$(
$(
map.insert($key, &$name);
)*
)*
map
};
}
};
}

Expand Down Expand Up @@ -109,6 +137,24 @@ define_counter_metrics!(
{ ADDED_TRANSACTIONS_SUCCESS, "ADDED_TRANSACTIONS_SUCCESS", "Number of successfully added transactions", 0 },
{ ADDED_TRANSACTIONS_FAILURE, "ADDED_TRANSACTIONS_FAILURE", "Number of faulty added transactions", 0 }
},
MetricScope::Infra => {
{ BATCHER_MSGS_RECEIVED, "batcher_msgs_received", "Counter of messages received by batcher component", 0 },
{ BATCHER_MSGS_PROCESSED, "batcher_msgs_processed", "Counter of messages processed by batcher component", 0 },
{ CLASS_MANAGER_MSGS_RECEIVED, "fs_class_manager_msgs_received", "Counter of messages received by class manager component", 0 },
{ CLASS_MANAGER_MSGS_PROCESSED, "fs_class_manager_msgs_processed", "Counter of messages processed by class manager component", 0 },
{ GATEWAY_MSGS_RECEIVED, "gateway_msgs_received", "Counter of messages received by gateway component", 0 },
{ GATEWAY_MSGS_PROCESSED, "gateway_msgs_processed", "Counter of messages processed by gateway component", 0 },
{ L1_PROVIDER_MSGS_RECEIVED, "l1_provider_msgs_received", "Counter of messages received by L1 provider component", 0 },
{ L1_PROVIDER_MSGS_PROCESSED, "l1_provider_msgs_processed", "Counter of messages processed by L1 provider component", 0 },
{ MEMPOOL_MSGS_RECEIVED, "mempool_communication_wrapper_msgs_received", "Counter of messages received by mempool component", 0 },
{ MEMPOOL_MSGS_PROCESSED, "mempool_communication_wrapper_msgs_processed", "Counter of messages processed by mempool component", 0 },
{ MEMPOOL_P2P_MSGS_RECEIVED, "mempool_p2p_propagator_msgs_received", "Counter of messages received by mempool p2p component", 0 },
{ MEMPOOL_P2P_MSGS_PROCESSED, "mempool_p2p_propagator_msgs_processed", "Counter of messages processed by mempool p2p component", 0 },
{ SIERRA_COMPILER_MSGS_RECEIVED, "sierra_compiler_msgs_received", "Counter of messages received by sierra compiler component", 0 },
{ SIERRA_COMPILER_MSGS_PROCESSED, "sierra_compiler_msgs_processed", "Counter of messages processed by sierra compiler component", 0 },
{ STATE_SYNC_MSGS_RECEIVED, "state_sync_msgs_received", "Counter of messages received by state sync component", 0 },
{ STATE_SYNC_MSGS_PROCESSED, "state_sync_msgs_processed", "Counter of messages processed by state sync component", 0 },
},
MetricScope::Network => {
{ MEMPOOL_P2P_NUM_SENT_MESSAGES, "apollo_mempool_num_sent_messages", "The number of messages sent by the mempool p2p component", 0 },
{ MEMPOOL_P2P_NUM_RECEIVED_MESSAGES, "apollo_mempool_num_received_messages", "The number of messages received by the mempool p2p component", 0 },
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_sequencer_metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use regex::{escape, Regex};
pub enum MetricScope {
Batcher,
HttpServer,
Infra,
Network,
PapyrusSync,
}
Expand Down

0 comments on commit 6985e91

Please sign in to comment.