message: Added histogram to track timing
diff: @@ -78,6 +78,8 @@ pub struct ContractRuntimeMetrics {
  run_query: Histogram,
  get_balance: Histogram,
  get_validator_weights: Histogram,
  + get_era_validators_timing: Histogram,
  + get_era_validator_weights_by_era_id_timing: Histogram,
  get_era_validators: Counter,
  get_era_validator_weights_by_era_id: Counter,
  }
  @@ -101,6 +103,12 @@ const GET_BALANCE_NAME: &str = "contract_runtime_get_balance";
  const GET_BALANCE_HELP: &str = "tracking run of engine_state.get_balance.";
  const GET_VALIDATOR_WEIGHTS_NAME: &str = "contract_runtime_get_validator_weights";
  const GET_VALIDATOR_WEIGHTS_HELP: &str = "tracking run of engine_state.get_validator_weights.";
  +const GET_ERA_VALIDATORS_TIMING_NAME: &str = "contract_runtime_get_era_validators";
  +const GET_ERA_VALIDATORS_TIMING_HELP: &str = "tracking run of engine_state.get_era_validators";
  +const GET_ERA_VALIDATORS_WEIGHT_BY_ERA_ID_TIMING_NAME: &str =
  + "contract_runtime_get_era_validator_weights_by_era_id";
  +const GET_ERA_VALIDATORS_WEIGHT_BY_ERA_ID_TIMING_HELP: &str =
  + "tracking run of engine_state.get_era_validator_weights_by_era_id";
  /// Create prometheus Histogram and register.
  fn register_histogram_metric(
  @@ -148,6 +156,16 @@ impl ContractRuntimeMetrics {
  GET_VALIDATOR_WEIGHTS_NAME,
  GET_VALIDATOR_WEIGHTS_HELP,
  )?,
  + get_era_validators_timing: register_histogram_metric(
  + registry,
  + GET_ERA_VALIDATORS_TIMING_NAME,
  + GET_ERA_VALIDATORS_TIMING_HELP,
  + )?,
  + get_era_validator_weights_by_era_id_timing: register_histogram_metric(
  + registry,
  + GET_ERA_VALIDATORS_WEIGHT_BY_ERA_ID_TIMING_NAME,
  + GET_ERA_VALIDATORS_WEIGHT_BY_ERA_ID_TIMING_HELP,
  + )?,
  get_era_validators,
  get_era_validator_weights_by_era_id,
  })
  @@ -321,7 +339,9 @@ where
  let start = Instant::now();
  let era_validators =
  engine_state.get_era_validators(correlation_id, request.into());
  - metrics.get_balance.observe(start.elapsed().as_secs_f64());
  + metrics
  + .get_era_validators_timing
  + .observe(start.elapsed().as_secs_f64());
  era_validators
  })
  .await
  @@ -357,7 +377,9 @@ where
  Err(GetEraValidatorsError::EraValidatorsMissing) => Ok(None),
  Err(error) => Err(error),
  };
  - metrics.get_balance.observe(start.elapsed().as_secs_f64());
  + metrics
  + .get_era_validator_weights_by_era_id_timing
  + .observe(start.elapsed().as_secs_f64());
  ret
  })
  .await
  