44use aptos_metrics_core:: {
55 exponential_buckets, register_avg_counter_vec, register_histogram, register_histogram_vec,
66 register_int_counter, register_int_counter_vec, register_int_gauge, Histogram , HistogramVec ,
7- IntCounter , IntCounterVec , IntGauge ,
7+ IntCounter , IntCounterVec , IntGauge , TimerHelper ,
88} ;
99use aptos_mvhashmap:: BlockStateStats ;
1010use aptos_types:: fee_statement:: FeeStatement ;
@@ -242,29 +242,35 @@ pub static BLOCK_VIEW_BASE_VALUES_MEMORY_USAGE: Lazy<HistogramVec> = Lazy::new(|
242242} ) ;
243243
244244fn observe_gas ( counter : & Lazy < HistogramVec > , mode_str : & str , fee_statement : & FeeStatement ) {
245- counter
246- . with_label_values ( & [ mode_str, GasType :: TOTAL_GAS ] )
247- . observe ( fee_statement. gas_used ( ) as f64 ) ;
248-
249- counter
250- . with_label_values ( & [ mode_str, GasType :: EXECUTION_GAS ] )
251- . observe ( fee_statement. execution_gas_used ( ) as f64 ) ;
252-
253- counter
254- . with_label_values ( & [ mode_str, GasType :: IO_GAS ] )
255- . observe ( fee_statement. io_gas_used ( ) as f64 ) ;
256-
257- counter
258- . with_label_values ( & [ mode_str, GasType :: NON_STORAGE_GAS ] )
259- . observe ( ( fee_statement. execution_gas_used ( ) + fee_statement. io_gas_used ( ) ) as f64 ) ;
260-
261- counter
262- . with_label_values ( & [ mode_str, GasType :: STORAGE_FEE ] )
263- . observe ( fee_statement. storage_fee_used ( ) as f64 ) ;
264-
265- counter
266- . with_label_values ( & [ mode_str, GasType :: STORAGE_FEE_REFUND ] )
267- . observe ( fee_statement. storage_fee_refund ( ) as f64 ) ;
245+ counter. observe_with (
246+ & [ mode_str, GasType :: TOTAL_GAS ] ,
247+ fee_statement. gas_used ( ) as f64 ,
248+ ) ;
249+
250+ counter. observe_with (
251+ & [ mode_str, GasType :: EXECUTION_GAS ] ,
252+ fee_statement. execution_gas_used ( ) as f64 ,
253+ ) ;
254+
255+ counter. observe_with (
256+ & [ mode_str, GasType :: IO_GAS ] ,
257+ fee_statement. io_gas_used ( ) as f64 ,
258+ ) ;
259+
260+ counter. observe_with (
261+ & [ mode_str, GasType :: NON_STORAGE_GAS ] ,
262+ ( fee_statement. execution_gas_used ( ) + fee_statement. io_gas_used ( ) ) as f64 ,
263+ ) ;
264+
265+ counter. observe_with (
266+ & [ mode_str, GasType :: STORAGE_FEE ] ,
267+ fee_statement. storage_fee_used ( ) as f64 ,
268+ ) ;
269+
270+ counter. observe_with (
271+ & [ mode_str, GasType :: STORAGE_FEE_REFUND ] ,
272+ fee_statement. storage_fee_refund ( ) as f64 ,
273+ ) ;
268274}
269275
270276pub ( crate ) fn update_block_gas_counters (
@@ -281,17 +287,11 @@ pub(crate) fn update_block_gas_counters(
281287 } ;
282288
283289 observe_gas ( & BLOCK_GAS , mode_str, accumulated_fee_statement) ;
284- BLOCK_COMMITTED_TXNS
285- . with_label_values ( & [ mode_str] )
286- . observe ( num_committed as f64 ) ;
290+ BLOCK_COMMITTED_TXNS . observe_with ( & [ mode_str] , num_committed as f64 ) ;
287291
288- EFFECTIVE_BLOCK_GAS
289- . with_label_values ( & [ mode_str] )
290- . observe ( accumulated_effective_gas as f64 ) ;
292+ EFFECTIVE_BLOCK_GAS . observe_with ( & [ mode_str] , accumulated_effective_gas as f64 ) ;
291293
292- APPROX_BLOCK_OUTPUT_SIZE
293- . with_label_values ( & [ mode_str] )
294- . observe ( accumulated_approx_output_size as f64 ) ;
294+ APPROX_BLOCK_OUTPUT_SIZE . observe_with ( & [ mode_str] , accumulated_approx_output_size as f64 ) ;
295295}
296296
297297pub ( crate ) fn update_txn_gas_counters ( txn_fee_statements : & Vec < FeeStatement > , is_parallel : bool ) {
@@ -313,25 +313,29 @@ pub(crate) fn update_state_counters(block_state_stats: BlockStateStats, is_paral
313313 Mode :: SEQUENTIAL
314314 } ;
315315
316+ BLOCK_VIEW_DISTINCT_KEYS . observe_with (
317+ & [ mode_str, "resource" ] ,
318+ block_state_stats. num_resources as f64 ,
319+ ) ;
320+ BLOCK_VIEW_DISTINCT_KEYS . observe_with (
321+ & [ mode_str, "resource_group" ] ,
322+ block_state_stats. num_resource_groups as f64 ,
323+ ) ;
324+ BLOCK_VIEW_DISTINCT_KEYS . observe_with (
325+ & [ mode_str, "delayed_field" ] ,
326+ block_state_stats. num_delayed_fields as f64 ,
327+ ) ;
316328 BLOCK_VIEW_DISTINCT_KEYS
317- . with_label_values ( & [ mode_str, "resource" ] )
318- . observe ( block_state_stats. num_resources as f64 ) ;
319- BLOCK_VIEW_DISTINCT_KEYS
320- . with_label_values ( & [ mode_str, "resource_group" ] )
321- . observe ( block_state_stats. num_resource_groups as f64 ) ;
322- BLOCK_VIEW_DISTINCT_KEYS
323- . with_label_values ( & [ mode_str, "delayed_field" ] )
324- . observe ( block_state_stats. num_delayed_fields as f64 ) ;
325- BLOCK_VIEW_DISTINCT_KEYS
326- . with_label_values ( & [ mode_str, "module" ] )
327- . observe ( block_state_stats. num_modules as f64 ) ;
328-
329- BLOCK_VIEW_BASE_VALUES_MEMORY_USAGE
330- . with_label_values ( & [ mode_str, "resource" ] )
331- . observe ( block_state_stats. base_resources_size as f64 ) ;
332- BLOCK_VIEW_BASE_VALUES_MEMORY_USAGE
333- . with_label_values ( & [ mode_str, "delayed_field" ] )
334- . observe ( block_state_stats. base_delayed_fields_size as f64 ) ;
329+ . observe_with ( & [ mode_str, "module" ] , block_state_stats. num_modules as f64 ) ;
330+
331+ BLOCK_VIEW_BASE_VALUES_MEMORY_USAGE . observe_with (
332+ & [ mode_str, "resource" ] ,
333+ block_state_stats. base_resources_size as f64 ,
334+ ) ;
335+ BLOCK_VIEW_BASE_VALUES_MEMORY_USAGE . observe_with (
336+ & [ mode_str, "delayed_field" ] ,
337+ block_state_stats. base_delayed_fields_size as f64 ,
338+ ) ;
335339}
336340
337341pub static GLOBAL_MODULE_CACHE_SIZE_IN_BYTES : Lazy < IntGauge > = Lazy :: new ( || {
0 commit comments