Skip to content

Commit

Permalink
[vm] add new libra_vm_critical_errors counter
Browse files Browse the repository at this point in the history
When the VM hits critical internal errors, we want to trigger alerts.
Alerts are currently based on Prometheus counters, so this change adds
a counter to use whenever something really bad happens inside the VM.

Closes: #6122
  • Loading branch information
Bob Wilson authored and bors-libra committed Sep 22, 2020
1 parent bc58400 commit 9983c1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions language/libra-vm/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ pub static TXN_GAS_USAGE: Lazy<Histogram> = Lazy::new(|| {
)
.unwrap()
});

/// Count the number of critical errors. This is not intended for display
/// on a dashboard but rather for triggering alerts.
pub static CRITICAL_ERRORS: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!("libra_vm_critical_errors", "Number of critical errors").unwrap()
});
4 changes: 4 additions & 0 deletions language/libra-vm/src/libra_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::{
access_path_cache::AccessPathCache,
counters::*,
data_cache::{RemoteStorage, StateViewCache},
errors::{
convert_normal_prologue_error, convert_normal_success_epilogue_error,
Expand Down Expand Up @@ -84,6 +85,7 @@ impl LibraVMImpl {

pub(crate) fn publishing_option(&self) -> Result<&VMPublishingOption, VMStatus> {
self.publishing_option.as_ref().ok_or_else(|| {
CRITICAL_ERRORS.inc();
error!("VM Startup Failed. PublishingOption Not Found");
VMStatus::Error(StatusCode::VM_STARTUP_FAILURE)
})
Expand All @@ -100,13 +102,15 @@ impl LibraVMImpl {
.as_ref()
.map(|config| &config.gas_schedule)
.ok_or_else(|| {
CRITICAL_ERRORS.inc();
error!("VM Startup Failed. Gas Schedule Not Found");
VMStatus::Error(StatusCode::VM_STARTUP_FAILURE)
})
}

pub fn get_libra_version(&self) -> Result<LibraVersion, VMStatus> {
self.version.clone().ok_or_else(|| {
CRITICAL_ERRORS.inc();
error!("VM Startup Failed. Libra Version Not Found");
VMStatus::Error(StatusCode::VM_STARTUP_FAILURE)
})
Expand Down

0 comments on commit 9983c1a

Please sign in to comment.