From e367fa8e9f81ebf788ad2f495c97e4c8b65aced9 Mon Sep 17 00:00:00 2001 From: David Ventura Date: Fri, 13 Dec 2024 10:44:08 +0100 Subject: [PATCH] wip autometrics --- Cargo.lock | 424 +++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 3 + src/commands/start.rs | 20 ++ src/config.rs | 6 +- src/config/metrics.rs | 11 ++ src/session.rs | 21 +++ 6 files changed, 475 insertions(+), 10 deletions(-) create mode 100644 src/config/metrics.rs diff --git a/Cargo.lock b/Cargo.lock index 9f42bda6..d59c1f72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,6 +77,18 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -168,12 +180,56 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" +[[package]] +name = "async-trait" +version = "0.1.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "autometrics" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e23d87191207a9f451a6214e861a184cd6db30e910371e464839ecf385f09ce" +dependencies = [ + "autometrics-macros", + "cfg_aliases", + "http 1.2.0", + "linkme", + "metrics-exporter-prometheus", + "once_cell", + "opentelemetry-prometheus", + "opentelemetry_sdk", + "prometheus", + "prometheus-client", + "spez", + "thiserror", +] + +[[package]] +name = "autometrics-macros" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc9eeb66696a988c64d8bbb73a6c83d5df20fe2bf7222aaf12ba8cd51a9ebf45" +dependencies = [ + "percent-encoding 2.3.1", + "proc-macro2", + "quote", + "regex", + "syn 2.0.85", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -346,6 +402,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chacha20" version = "0.9.1" @@ -533,6 +595,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -655,6 +732,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "dtoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" + [[package]] name = "ecdsa" version = "0.16.9" @@ -909,6 +992,17 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "futures-sink" version = "0.3.31" @@ -928,6 +1022,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", + "futures-macro", "futures-sink", "futures-task", "pin-project-lite", @@ -963,6 +1058,12 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "group" version = "0.13.0" @@ -985,14 +1086,29 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", - "indexmap", + "http 0.2.12", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", "tracing", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.15.0" @@ -1008,7 +1124,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http", + "http 0.2.12", "httpdate", "mime", "sha1", @@ -1020,7 +1136,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.12", ] [[package]] @@ -1102,6 +1218,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1109,7 +1236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] @@ -1136,7 +1263,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", @@ -1204,6 +1331,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.6.0" @@ -1211,7 +1348,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -1317,6 +1454,26 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linkme" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566336154b9e58a4f055f6dd4cbab62c7dc0826ce3c0a04e63b2d2ecd784cdae" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edbe595006d355eaf9ae11db92707d4338cd2384d16866131cc1afdbdd35d8d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1339,6 +1496,15 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "matchers" version = "0.1.0" @@ -1372,6 +1538,57 @@ dependencies = [ "zeroize", ] +[[package]] +name = "metrics" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde3af1a009ed76a778cb84fdef9e7dbbdf5775ae3e4cc1f434a6a307f6f76c5" +dependencies = [ + "ahash", + "metrics-macros", + "portable-atomic", +] + +[[package]] +name = "metrics-exporter-prometheus" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950" +dependencies = [ + "base64 0.21.7", + "indexmap 1.9.3", + "metrics", + "metrics-util", + "quanta", + "thiserror", +] + +[[package]] +name = "metrics-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + +[[package]] +name = "metrics-util" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", + "hashbrown 0.13.1", + "metrics", + "num_cpus", + "quanta", + "sketches-ddsketch", +] + [[package]] name = "mime" version = "0.3.17" @@ -1465,6 +1682,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.32.2" @@ -1530,6 +1757,49 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "opentelemetry" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c365a63eec4f55b7efeceb724f1336f26a9cf3427b70e59e2cd2a5b947fba96" +dependencies = [ + "futures-core", + "futures-sink", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "opentelemetry-prometheus" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4191ce34aa274621861a7a9d68dbcf618d5b6c66b10081631b61fd81fbc015" +dependencies = [ + "once_cell", + "opentelemetry", + "opentelemetry_sdk", + "prometheus", + "protobuf", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692eac490ec80f24a17828d49b40b60f5aeaccdfe6a503f939713afd22bc28df" +dependencies = [ + "async-trait", + "futures-channel", + "futures-executor", + "futures-util", + "glob", + "once_cell", + "opentelemetry", + "thiserror", +] + [[package]] name = "overload" version = "0.1.1" @@ -1566,6 +1836,29 @@ dependencies = [ "sha2 0.10.8", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + [[package]] name = "paste" version = "1.0.15" @@ -1633,6 +1926,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -1666,6 +1965,44 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prometheus" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" +dependencies = [ + "cfg-if 1.0.0", + "fnv", + "lazy_static", + "memchr", + "parking_lot", + "protobuf", + "thiserror", +] + +[[package]] +name = "prometheus-client" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" +dependencies = [ + "dtoa", + "itoa", + "parking_lot", + "prometheus-client-derive-encode", +] + +[[package]] +name = "prometheus-client-derive-encode" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "prost" version = "0.12.6" @@ -1698,6 +2035,28 @@ dependencies = [ "prost", ] +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" + +[[package]] +name = "quanta" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab" +dependencies = [ + "crossbeam-utils", + "libc", + "mach2", + "once_cell", + "raw-cpuid", + "wasi", + "web-sys", + "winapi", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -1743,6 +2102,24 @@ dependencies = [ "getrandom", ] +[[package]] +name = "raw-cpuid" +version = "10.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "regex" version = "1.11.1" @@ -2102,13 +2479,19 @@ checksum = "fad8561dab46cf18be56eef057219f48f576d6bb91847cc33d7d4f2779bcd217" dependencies = [ "futures-executor", "headers", - "http", + "http 0.2.12", "hyper", "tokio", "tokio-native-tls", "tokio-stream", ] +[[package]] +name = "sketches-ddsketch" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85636c14b73d81f541e525f585c0a2109e6744e1565b5c1668e31c70c10ed65c" + [[package]] name = "slab" version = "0.4.9" @@ -2134,6 +2517,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "spez" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87e960f4dca2788eeb86bbdde8dd246be8948790b7618d656e68f9b720a86e8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "spin" version = "0.9.8" @@ -2424,6 +2818,7 @@ name = "tmkms" version = "0.14.0" dependencies = [ "abscissa_core", + "autometrics", "byteorder", "bytes", "chrono", @@ -2457,6 +2852,7 @@ dependencies = [ "tendermint-p2p", "tendermint-proto", "thiserror", + "tiny_http", "url 2.5.2", "uuid", "wait-timeout", @@ -2561,7 +2957,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -2837,6 +3233,16 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +[[package]] +name = "web-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 8626e58e..39fc3457 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ rust-version = "1.74" [dependencies] abscissa_core = "0.7" +autometrics = { version = "2.0.0", features = ["prometheus-exporter"], optional = true } bytes = "1" chrono = "0.4" clap = "4" @@ -48,6 +49,7 @@ tendermint-config = "0.35" tendermint-p2p = "0.35" tendermint-proto = "0.35" thiserror = "1" +tiny_http = "0.12.0" url = { version = "2.2.2", features = ["serde"], optional = true } uuid = { version = "1", features = ["serde"], optional = true } wait-timeout = "0.2" @@ -64,6 +66,7 @@ softsign = [] yubihsm-mock = ["yubihsm/mockhsm"] yubihsm-server = ["yubihsm/http-server", "rpassword"] fortanixdsm = ["elliptic-curve", "sdkms", "url", "uuid"] +prometheus-exporter = ["autometrics"] # Enable integer overflow checks in release builds for security reasons [profile.release] diff --git a/src/commands/start.rs b/src/commands/start.rs index 0df75528..1e800c94 100644 --- a/src/commands/start.rs +++ b/src/commands/start.rs @@ -2,6 +2,7 @@ use crate::{chain, client::Client, prelude::*}; use abscissa_core::Command; +use autometrics::prometheus_exporter; use clap::Parser; use std::{path::PathBuf, process}; @@ -26,6 +27,25 @@ impl Runnable for StartCommand { env!("CARGO_PKG_VERSION") ); + let metrics_config = APP.config().metrics.clone(); + if let Some(address) = metrics_config.bind_address { + info!("Starting up prometheus server on {}", address); + prometheus_exporter::init(); + let thread_name = abscissa_core::thread::Name::new("prometheus-thread").unwrap(); + APP.state() + .threads_mut() + .spawn(thread_name, move || { + let server = + tiny_http::Server::http(address).expect("Unable to bind to address"); + for request in server.incoming_requests() { + let response = prometheus_exporter::encode_to_string().unwrap(); + request + .respond(tiny_http::Response::from_string(response)) + .unwrap(); + } + }) + .expect("Unable to start prometheus exporter thread"); + } run_app(self.spawn_clients()); } } diff --git a/src/config.rs b/src/config.rs index 3f08374c..5449810e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,12 +1,13 @@ //! Configuration file structures (with serde-derived parser) pub mod chain; +pub mod metrics; pub mod provider; pub mod validator; pub use self::validator::*; -use self::{chain::ChainConfig, provider::ProviderConfig}; +use self::{chain::ChainConfig, metrics::MetricsConfig, provider::ProviderConfig}; use serde::Deserialize; /// Environment variable containing path to config file @@ -29,4 +30,7 @@ pub struct KmsConfig { /// Addresses of validator nodes #[serde(default)] pub validator: Vec, + + /// Metrics configuration + pub metrics: MetricsConfig, } diff --git a/src/config/metrics.rs b/src/config/metrics.rs new file mode 100644 index 00000000..b070554a --- /dev/null +++ b/src/config/metrics.rs @@ -0,0 +1,11 @@ +//! Metrics configuration + +use serde::Deserialize; + +/// Metrics configuration +#[derive(Deserialize, Debug, Clone, Default)] +#[serde(deny_unknown_fields)] +pub struct MetricsConfig { + /// Address on which to bind metrics exporter + pub bind_address: Option, +} diff --git a/src/session.rs b/src/session.rs index d61f7831..915a478e 100644 --- a/src/session.rs +++ b/src/session.rs @@ -9,11 +9,28 @@ use crate::{ privval::SignableMsg, rpc::{Request, Response}, }; +use autometrics::{ + autometrics, + objectives::{Objective, ObjectiveLatency, ObjectivePercentile}, +}; use std::{os::unix::net::UnixStream, time::Instant}; use tendermint::{consensus, TendermintKey}; use tendermint_config::net; use tendermint_proto as proto; +const REQUEST_SLO: Objective = + Objective::new("validator-request").success_rate(ObjectivePercentile::P99_9); + +const SIGN_SLO: Objective = Objective::new("sign-request") + .success_rate(ObjectivePercentile::P99_9) + .latency(ObjectiveLatency::Ms500, ObjectivePercentile::P99) + .latency(ObjectiveLatency::Ms1000, ObjectivePercentile::P99_9); + +const GET_PUBKEY_SLO: Objective = Objective::new("pubkey-request") + .success_rate(ObjectivePercentile::P99_9) + .latency(ObjectiveLatency::Ms500, ObjectivePercentile::P99) + .latency(ObjectiveLatency::Ms1000, ObjectivePercentile::P99_9); + /// Encrypted session with a validator node pub struct Session { /// Validator configuration options @@ -95,6 +112,7 @@ impl Session { } /// Handle an incoming request from the validator + #[autometrics(objective = REQUEST_SLO, ok_if = Result::is_ok)] fn handle_request(&mut self) -> Result { let request = Request::read(&mut self.connection, &self.config.chain_id)?; debug!( @@ -123,6 +141,7 @@ impl Session { } /// Perform a digital signature operation + #[autometrics(objective = SIGN_SLO, ok_if = Result::is_ok)] fn sign(&mut self, mut signable_msg: SignableMsg) -> Result { self.check_max_height(&signable_msg)?; @@ -222,6 +241,7 @@ impl Session { } /// Get the public key for (the only) public key in the keyring + #[autometrics(objective = GET_PUBKEY_SLO, ok_if = Result::is_ok)] fn get_public_key(&mut self) -> Result { let registry = chain::REGISTRY.get(); @@ -266,6 +286,7 @@ impl Session { } /// Double signing handler. +#[autometrics] fn double_sign(consensus_state: consensus::State) -> proto::privval::RemoteSignerError { /// Double signing error code. const DOUBLE_SIGN_ERROR: i32 = 2;