Skip to content

Commit

Permalink
Count in-flight GRPC requests via request lifecycle metrics (MystenLa…
Browse files Browse the repository at this point in the history
…bs#4494)

This is a fix on top of MystenLabs#4489 that uses more reliable lifecycle metrics introduced in MystenLabs/mysten-infra#142

Also adds request counter to see total number of requests
  • Loading branch information
andll authored Sep 6, 2022
1 parent 21780d1 commit b8cf893
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 432 deletions.
665 changes: 293 additions & 372 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/sui-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rocksdb = "0.19.0"
serde_with = { version = "1.14.0", features = ["hex"] }
tracing = "0.1.36"
tracing-subscriber = { version = "0.3.15", features = ["time", "registry", "env-filter"] }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
clap = { version = "3.1.17", features = ["derive"] }
prometheus = "0.13.1"
multiaddr = "0.14.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-cluster-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tokio = { version = "1.20.1", features = ["full"] }
tracing = { version = "0.1.36", features = ["log"] }
clap = { version = "3.1.14", features = ["derive"] }
reqwest = { version = "0.11.11", features = ["blocking", "json"] }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
async-trait = "0.1.57"
anyhow = { version = "1.0.58", features = ["backtrace"] }
bcs = "0.1.3"
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "70
move-core-types = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2", features = ["address20"] }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }

typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }

narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "842a611a0a58dd378a904d85f79b4edbbbc7b137", package = "config" }
narwhal-consensus = { git = "https://github.com/MystenLabs/narwhal", rev = "842a611a0a58dd378a904d85f79b4edbbbc7b137", package = "consensus" }
Expand All @@ -69,7 +69,7 @@ move-package = { git = "https://github.com/move-language/move", rev = "70b34a664
serde-reflection = "0.3.6"
serde_yaml = "0.8.26"
pretty_assertions = "1.2.1"
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }

test-fuzz = "3.0.4"
test-utils = { path = "../test-utils" }
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sui-node = { path = "../sui-node" }
sui-json-rpc-types= { path = "../sui-json-rpc-types" }
sui-types = { path = "../sui-types" }
sui-config = { path = "../sui-config" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
workspace-hack = { path = "../workspace-hack"}

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tokio = { version = "1.20.1", features = ["full"] }
futures = "0.3.23"
prometheus = "0.13.1"
clap = { version = "3.2.17", features = ["derive"] }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }

sui-core = { path = "../sui-core" }
sui-config = { path = "../sui-config" }
Expand All @@ -25,7 +25,7 @@ sui-json-rpc = { path = "../sui-json-rpc" }
sui-json-rpc-types= { path = "../sui-json-rpc-types" }
sui-node = { path = "../sui-node" }

mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
move-package = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }
workspace-hack = { path = "../workspace-hack"}

Expand Down
2 changes: 1 addition & 1 deletion crates/sui-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tonic = "0.7"

sui-types = { path = "../sui-types" }

mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
workspace-hack = { path = "../workspace-hack"}

[build-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tokio = { version = "1.20.1", features = ["full"] }
tracing = "0.1.36"
parking_lot = "0.12.1"
futures = "0.3.23"
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
chrono = "0.4.0"

sui-config = { path = "../sui-config" }
Expand All @@ -28,8 +28,8 @@ sui-telemetry = { path = "../sui-telemetry" }
sui-types = { path = "../sui-types" }
sui-quorum-driver = { path = "../sui-quorum-driver" }

telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
workspace-hack = { path = "../workspace-hack"}

[target.'cfg(not(target_env = "msvc"))'.dependencies]
Expand Down
34 changes: 28 additions & 6 deletions crates/sui-node/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

use axum::{extract::Extension, http::StatusCode, routing::get, Router};
use mysten_network::metrics::MetricsCallbackProvider;
use prometheus::{register_int_gauge_vec_with_registry, IntGaugeVec, Registry, TextEncoder};
use prometheus::{
register_int_counter_vec_with_registry, register_int_gauge_vec_with_registry, IntCounterVec,
IntGaugeVec, Registry, TextEncoder,
};
use std::net::SocketAddr;
use std::time::Duration;
use sui_network::tonic::Code;
Expand Down Expand Up @@ -41,14 +44,22 @@ async fn metrics(Extension(registry): Extension<Registry>) -> (StatusCode, Strin
#[derive(Clone)]
pub struct GrpcMetrics {
inflight_grpc: IntGaugeVec,
grpc_requests: IntCounterVec,
}

impl GrpcMetrics {
pub fn new(registry: &Registry) -> Self {
Self {
inflight_grpc: register_int_gauge_vec_with_registry!(
"inflight_grpc",
"Total in-flight GRPC per route",
"Total in-flight GRPC requests per route",
&["path"],
registry,
)
.unwrap(),
grpc_requests: register_int_counter_vec_with_registry!(
"grpc_requests",
"Total GRPC requests per route",
&["path"],
registry,
)
Expand All @@ -58,11 +69,22 @@ impl GrpcMetrics {
}

impl MetricsCallbackProvider for GrpcMetrics {
fn on_request(&self, path: String) {
self.inflight_grpc.with_label_values(&[&path]).inc();
fn on_request(&self, _path: String) {}
fn on_response(
&self,
_path: String,
_latency: Duration,
_status: u16,
_grpc_status_code: Code,
) {
}

fn on_start(&self, path: &str) {
self.inflight_grpc.with_label_values(&[path]).inc();
self.grpc_requests.with_label_values(&[path]).inc();
}

fn on_response(&self, path: String, _latency: Duration, _status: u16, _grpc_status_code: Code) {
self.inflight_grpc.with_label_values(&[&path]).dec();
fn on_drop(&self, path: &str) {
self.inflight_grpc.with_label_values(&[path]).dec();
}
}
6 changes: 3 additions & 3 deletions crates/sui-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ tempfile = "3.3.0"
tap = "1.0.1"

sui-types = { path = "../sui-types" }
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
move-core-types = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2", features = ["address20"] }
sui-json-rpc-types = { path = "../sui-json-rpc-types" }
workspace-hack = { path = "../workspace-hack"}
Expand All @@ -39,7 +39,7 @@ anyhow = "1.0.58"
tempfile = "3.3.0"
num_cpus = "1.13.1"
pretty_assertions = "1.2.0"
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }

[[bench]]
name = "write_ahead_log"
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-swarm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ sui-config = { path = "../sui-config" }
sui-node = { path = "../sui-node" }
sui-types = { path = "../sui-types" }

mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
workspace-hack = { path = "../workspace-hack"}

[dev-dependencies]
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
8 changes: 4 additions & 4 deletions crates/sui-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ anyhow = { version = "1.0.58", features = ["backtrace"] }
tokio = { version = "1.20.1", features = ["full"] }
tracing = "0.1.36"
clap = { version = "3.2.17", features = ["derive"] }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
textwrap = "0.15"
futures = "0.3.23"
rocksdb = "0.19.0"
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
tempfile = "3.3.0"
narwhal-executor = { git = "https://github.com/MystenLabs/narwhal", rev = "842a611a0a58dd378a904d85f79b4edbbbc7b137", package = "executor" }
serde_with = { version = "1.14.0", features = ["hex"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ roaring = "0.9.0"
enum_dispatch = "^0.3"
eyre = "0.6.8"

name-variant = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
name-variant = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }

move-binary-format = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }
Expand Down
10 changes: 5 additions & 5 deletions crates/sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ serde_with = { version = "1.14.0", features = ["hex"] }
tracing = "0.1.36"
bcs = "0.1.3"
clap = { version = "3.2.17", features = ["derive"] }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445" }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8" }

sui-core = { path = "../sui-core" }
sui-framework = { path = "../sui-framework" }
Expand All @@ -36,8 +36,8 @@ colored = "2.0.0"
unescape = "0.1.0"
shell-words = "1.1.0"
rocksdb = "0.19.0"
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
tempfile = "3.3.0"
narwhal-executor = { git = "https://github.com/MystenLabs/narwhal", rev = "842a611a0a58dd378a904d85f79b4edbbbc7b137", package = "executor" }

Expand All @@ -59,8 +59,8 @@ jemalloc-ctl = "^0.5"
[dev-dependencies]
tempfile = "3.3.0"
futures = "0.3.23"
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7ef7415a4e11cf68fa68ce9db884c46e704e0445"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
typed-store-macros = { git = "https://github.com/MystenLabs/mysten-infra", rev = "0a2956d113d29369a8c05bd492c51ca0ff3423e8"}
jsonrpsee = { version = "0.15.1", features = ["full"] }

test-utils = { path = "../test-utils" }
Expand Down
Loading

0 comments on commit b8cf893

Please sign in to comment.