File tree Expand file tree Collapse file tree 6 files changed +30
-16
lines changed
apollo_dashboard/src/panels Expand file tree Collapse file tree 6 files changed +30
-16
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ pub(crate) fn record_block_close_reason(reason: BlockCloseReason) {
7878}
7979
8080pub const BATCHER_CLASS_CACHE_METRICS : CacheMetrics =
81- CacheMetrics { misses : CLASS_CACHE_MISSES , hits : CLASS_CACHE_HITS } ;
81+ CacheMetrics :: new ( CLASS_CACHE_MISSES , CLASS_CACHE_HITS ) ;
8282
8383pub fn register_metrics ( storage_height : BlockNumber ) {
8484 STORAGE_HEIGHT . register ( ) ;
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ fn get_panel_blockifier_state_reader_class_cache_miss_ratio(
3838 Panel :: ratio_time_series (
3939 name. as_str ( ) ,
4040 description. as_str ( ) ,
41- & class_cache_metrics. misses ,
42- & [ & class_cache_metrics. misses , & class_cache_metrics. hits ] ,
41+ class_cache_metrics. misses ( ) ,
42+ & [ class_cache_metrics. misses ( ) , class_cache_metrics. hits ( ) ] ,
4343 BLOCKIFIER_METRIC_RATE_DURATION ,
4444 )
4545}
@@ -54,7 +54,7 @@ fn get_panel_blockifier_state_reader_native_class_returned_ratio() -> Panel {
5454 name,
5555 description,
5656 & NATIVE_CLASS_RETURNED ,
57- & [ & class_cache_metrics. misses , & class_cache_metrics. hits ] ,
57+ & [ class_cache_metrics. misses ( ) , class_cache_metrics. hits ( ) ] ,
5858 BLOCKIFIER_METRIC_RATE_DURATION ,
5959 )
6060}
Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ impl Drop for GatewayMetricHandle {
247247}
248248
249249pub const GATEWAY_CLASS_CACHE_METRICS : CacheMetrics =
250- CacheMetrics { misses : CLASS_CACHE_MISSES , hits : CLASS_CACHE_HITS } ;
250+ CacheMetrics :: new ( CLASS_CACHE_MISSES , CLASS_CACHE_HITS ) ;
251251
252252pub ( crate ) fn register_metrics ( ) {
253253 GATEWAY_CLASS_CACHE_METRICS . register ( ) ;
Original file line number Diff line number Diff line change @@ -29,10 +29,23 @@ define_metrics!(
2929
3030pub const BLOCKIFIER_METRIC_RATE_DURATION : & str = "5m" ;
3131
32- // TODO(Arni): Fix visibility of members of this struct (make them not public).
3332pub struct CacheMetrics {
34- pub misses : MetricCounter ,
35- pub hits : MetricCounter ,
33+ misses : MetricCounter ,
34+ hits : MetricCounter ,
35+ }
36+
37+ impl CacheMetrics {
38+ pub const fn new ( misses : MetricCounter , hits : MetricCounter ) -> Self {
39+ Self { misses, hits }
40+ }
41+
42+ pub fn misses ( & self ) -> & MetricCounter {
43+ & self . misses
44+ }
45+
46+ pub fn hits ( & self ) -> & MetricCounter {
47+ & self . hits
48+ }
3649}
3750
3851impl CacheMetrics {
@@ -55,6 +68,7 @@ impl CacheMetrics {
5568 self . hits. get_scope( ) ,
5669 "Scope of misses and hits must be the same"
5770 ) ;
71+
5872 self . misses . get_scope ( )
5973 }
6074}
Original file line number Diff line number Diff line change @@ -22,20 +22,20 @@ use crate::test_utils::contracts::FeatureContractData;
2222use crate :: test_utils:: dict_state_reader:: DictStateReader ;
2323
2424/// Placeholder class cache metrics. The metrics are not tested in the blockifier's context.
25- const BLOCKIFIER_CLASS_CACHE_METRICS : CacheMetrics = CacheMetrics {
26- misses : MetricCounter :: new (
25+ const BLOCKIFIER_CLASS_CACHE_METRICS : CacheMetrics = CacheMetrics :: new (
26+ MetricCounter :: new (
2727 MetricScope :: Blockifier ,
2828 "Class Cache Misses in Blockifier" ,
2929 "Counter of the number of times that the class cache was missed" ,
3030 0 ,
3131 ) ,
32- hits : MetricCounter :: new (
32+ MetricCounter :: new (
3333 MetricScope :: Blockifier ,
3434 "Class Cache Misses in Blockifier" ,
3535 "Counter of the number of times that the class cache was hit" ,
3636 0 ,
3737 ) ,
38- } ;
38+ ) ;
3939
4040/// Utility to fund an account.
4141pub fn fund_account (
Original file line number Diff line number Diff line change @@ -55,20 +55,20 @@ pub type ApolloStateReaderAndContractManager = StateReaderAndContractManager<Apo
5555const RESULT_SERIALIZE_ERR : & str = "Failed serializing execution info." ;
5656
5757/// Placeholder class cache metrics. There are not metrics on the native blockifier.
58- const NATIVE_BLOCKIFIER_CLASS_CACHE_METRICS : CacheMetrics = CacheMetrics {
59- misses : MetricCounter :: new (
58+ const NATIVE_BLOCKIFIER_CLASS_CACHE_METRICS : CacheMetrics = CacheMetrics :: new (
59+ MetricCounter :: new (
6060 MetricScope :: Blockifier ,
6161 "Class Cache Misses in Native Blockifier" ,
6262 "Counter of the number of times that the class cache was missed" ,
6363 0 ,
6464 ) ,
65- hits : MetricCounter :: new (
65+ MetricCounter :: new (
6666 MetricScope :: Blockifier ,
6767 "Class Cache Misses in Native Blockifier" ,
6868 "Counter of the number of times that the class cache was hit" ,
6969 0 ,
7070 ) ,
71- } ;
71+ ) ;
7272
7373/// Return type for the finalize method containing state diffs, bouncer weights, and CASM hash
7474/// computation data.
You can’t perform that action at this time.
0 commit comments