pub(super) fn new(registry: &Registry) -> Result<Self, prometheus::Error> {
        let common_buckets = prometheus::exponential_buckets(
            EXPONENTIAL_BUCKET_START,
            EXPONENTIAL_BUCKET_FACTOR,
            EXPONENTIAL_BUCKET_COUNT,
        )?;

        let chain_height = IntGauge::new(CHAIN_HEIGHT_NAME, CHAIN_HEIGHT_HELP)?;
        registry.register(Box::new(chain_height.clone()))?;

        let latest_commit_step = Gauge::new(LATEST_COMMIT_STEP_NAME, LATEST_COMMIT_STEP_HELP)?;
        registry.register(Box::new(latest_commit_step.clone()))?;

        Ok(Metrics {
            run_execute: utils::register_histogram_metric(
                registry,
                RUN_EXECUTE_NAME,
                RUN_EXECUTE_HELP,
                common_buckets.clone(),
            )?,
            apply_effect: utils::register_histogram_metric(
                registry,
                APPLY_EFFECT_NAME,
                APPLY_EFFECT_HELP,
                common_buckets.clone(),
            )?,
            run_query: utils::register_histogram_metric(
                registry,
                RUN_QUERY_NAME,
                RUN_QUERY_HELP,
                common_buckets.clone(),
            )?,
            commit_step: utils::register_histogram_metric(
                registry,
                COMMIT_STEP_NAME,
                COMMIT_STEP_HELP,
                common_buckets.clone(),
            )?,
            commit_upgrade: utils::register_histogram_metric(
                registry,
                COMMIT_UPGRADE_NAME,
                COMMIT_UPGRADE_HELP,
                common_buckets.clone(),
            )?,
            get_balance: utils::register_histogram_metric(
                registry,
                GET_BALANCE_NAME,
                GET_BALANCE_HELP,
                common_buckets.clone(),
            )?,
            get_validator_weights: utils::register_histogram_metric(
                registry,
                GET_VALIDATOR_WEIGHTS_NAME,
                GET_VALIDATOR_WEIGHTS_HELP,
                common_buckets.clone(),
            )?,
            get_era_validators: utils::register_histogram_metric(
                registry,
                GET_ERA_VALIDATORS_NAME,
                GET_ERA_VALIDATORS_HELP,
                common_buckets.clone(),
            )?,
            get_bids: utils::register_histogram_metric(
                registry,
                GET_BIDS_NAME,
                GET_BIDS_HELP,
                common_buckets.clone(),
            )?,
            get_trie: utils::register_histogram_metric(
                registry,
                GET_TRIE_NAME,
                GET_TRIE_HELP,
                common_buckets.clone(),
            )?,
            put_trie: utils::register_histogram_metric(
                registry,
                PUT_TRIE_NAME,
                PUT_TRIE_HELP,
                common_buckets.clone(),
            )?,
            missing_trie_keys: utils::register_histogram_metric(
                registry,
                MISSING_TRIE_KEYS_NAME,
                MISSING_TRIE_KEYS_HELP,
                common_buckets.clone(),
            )?,
            chain_height,
            exec_block: utils::register_histogram_metric(
                registry,
                EXEC_BLOCK_NAME,
                EXEC_BLOCK_HELP,
                common_buckets,
            )?,
            latest_commit_step,
            registry: registry.clone(),
        })
    }
/// Constructor of metrics which creates and registers metrics objects for use.
Constructor of metrics which creates and registers metrics objects for use.
Constructor of metrics which creates and registers metrics objects for use .
pub(super) fn new(registry: &Registry) -> Result<Self, prometheus::Error> {
        let common_buckets = prometheus::exponential_buckets(
            EXPONENTIAL_BUCKET_START,
            EXPONENTIAL_BUCKET_FACTOR,
            EXPONENTIAL_BUCKET_COUNT,
        )?;
        let chain_height = IntGauge::new(CHAIN_HEIGHT_NAME, CHAIN_HEIGHT_HELP)?;
        registry.register(Box::new(chain_height.clone()))?;
        let latest_commit_step = Gauge::new(LATEST_COMMIT_STEP_NAME, LATEST_COMMIT_STEP_HELP)?;
        registry.register(Box::new(latest_commit_step.clone()))?;
        Ok(Metrics {
            run_execute: utils::register_histogram_metric(
                registry,
                RUN_EXECUTE_NAME,
                RUN_EXECUTE_HELP,
                common_buckets.clone(),
            )?,
            apply_effect: utils::register_histogram_metric(
                registry,
                APPLY_EFFECT_NAME,
                APPLY_EFFECT_HELP,
                common_buckets.clone(),
            )?,
            run_query: utils::register_histogram_metric(
                registry,
                RUN_QUERY_NAME,
                RUN_QUERY_HELP,
                common_buckets.clone(),
            )?,
            commit_step: utils::register_histogram_metric(
                registry,
                COMMIT_STEP_NAME,
                COMMIT_STEP_HELP,
                common_buckets.clone(),
            )?,
            commit_upgrade: utils::register_histogram_metric(
                registry,
                COMMIT_UPGRADE_NAME,
                COMMIT_UPGRADE_HELP,
                common_buckets.clone(),
            )?,
            get_balance: utils::register_histogram_metric(
                registry,
                GET_BALANCE_NAME,
                GET_BALANCE_HELP,
                common_buckets.clone(),
            )?,
            get_validator_weights: utils::register_histogram_metric(
                registry,
                GET_VALIDATOR_WEIGHTS_NAME,
                GET_VALIDATOR_WEIGHTS_HELP,
                common_buckets.clone(),
            )?,
            get_era_validators: utils::register_histogram_metric(
                registry,
                GET_ERA_VALIDATORS_NAME,
                GET_ERA_VALIDATORS_HELP,
                common_buckets.clone(),
            )?,
            get_bids: utils::register_histogram_metric(
                registry,
                GET_BIDS_NAME,
                GET_BIDS_HELP,
                common_buckets.clone(),
            )?,
            get_trie: utils::register_histogram_metric(
                registry,
                GET_TRIE_NAME,
                GET_TRIE_HELP,
                common_buckets.clone(),
            )?,
            put_trie: utils::register_histogram_metric(
                registry,
                PUT_TRIE_NAME,
                PUT_TRIE_HELP,
                common_buckets.clone(),
            )?,
            missing_trie_keys: utils::register_histogram_metric(
                registry,
                MISSING_TRIE_KEYS_NAME,
                MISSING_TRIE_KEYS_HELP,
                common_buckets.clone(),
            )?,
            chain_height,
            exec_block: utils::register_histogram_metric(
                registry,
                EXEC_BLOCK_NAME,
                EXEC_BLOCK_HELP,
                common_buckets,
            )?,
            latest_commit_step,
            registry: registry.clone(),
        })
    }
pub ( super ) fn new ( registry : & Registry ) -> Result < Self , prometheus :: Error > { let common_buckets = prometheus :: exponential_buckets ( EXPONENTIAL_BUCKET_START , EXPONENTIAL_BUCKET_FACTOR , EXPONENTIAL_BUCKET_COUNT , ) ? ; let chain_height = IntGauge :: new ( CHAIN_HEIGHT_NAME , CHAIN_HEIGHT_HELP ) ? ; registry . register ( Box :: new ( chain_height . clone ( ) ) ) ? ; let latest_commit_step = Gauge :: new ( LATEST_COMMIT_STEP_NAME , LATEST_COMMIT_STEP_HELP ) ? ; registry . register ( Box :: new ( latest_commit_step . clone ( ) ) ) ? ; Ok ( Metrics { run_execute : utils :: register_histogram_metric ( registry , RUN_EXECUTE_NAME , RUN_EXECUTE_HELP , common_buckets . clone ( ) , ) ? , apply_effect : utils :: register_histogram_metric ( registry , APPLY_EFFECT_NAME , APPLY_EFFECT_HELP , common_buckets . clone ( ) , ) ? , run_query : utils :: register_histogram_metric ( registry , RUN_QUERY_NAME , RUN_QUERY_HELP , common_buckets . clone ( ) , ) ? , commit_step : utils :: register_histogram_metric ( registry , COMMIT_STEP_NAME , COMMIT_STEP_HELP , common_buckets . clone ( ) , ) ? , commit_upgrade : utils :: register_histogram_metric ( registry , COMMIT_UPGRADE_NAME , COMMIT_UPGRADE_HELP , common_buckets . clone ( ) , ) ? , get_balance : utils :: register_histogram_metric ( registry , GET_BALANCE_NAME , GET_BALANCE_HELP , common_buckets . clone ( ) , ) ? , get_validator_weights : utils :: register_histogram_metric ( registry , GET_VALIDATOR_WEIGHTS_NAME , GET_VALIDATOR_WEIGHTS_HELP , common_buckets . clone ( ) , ) ? , get_era_validators : utils :: register_histogram_metric ( registry , GET_ERA_VALIDATORS_NAME , GET_ERA_VALIDATORS_HELP , common_buckets . clone ( ) , ) ? , get_bids : utils :: register_histogram_metric ( registry , GET_BIDS_NAME , GET_BIDS_HELP , common_buckets . clone ( ) , ) ? , get_trie : utils :: register_histogram_metric ( registry , GET_TRIE_NAME , GET_TRIE_HELP , common_buckets . clone ( ) , ) ? , put_trie : utils :: register_histogram_metric ( registry , PUT_TRIE_NAME , PUT_TRIE_HELP , common_buckets . clone ( ) , ) ? , missing_trie_keys : utils :: register_histogram_metric ( registry , MISSING_TRIE_KEYS_NAME , MISSING_TRIE_KEYS_HELP , common_buckets . clone ( ) , ) ? , chain_height , exec_block : utils :: register_histogram_metric ( registry , EXEC_BLOCK_NAME , EXEC_BLOCK_HELP , common_buckets , ) ? , latest_commit_step , registry : registry . clone ( ) , } ) }
Constructor of metrics which creates and registers metrics objects for use.
Constructor of metrics which creates and registers metrics objects for use .
registry
&Registry
registry
&Registry