add head_block, head_latency, and request_latency to popularity_contest table
This commit is contained in:
parent
b5d758032c
commit
e6ca8a5253
@ -1,7 +1,8 @@
|
||||
use std::{cmp::Reverse, collections::BTreeMap};
|
||||
use std::{cmp::Reverse, collections::BTreeMap, str::FromStr};
|
||||
|
||||
// show what nodes are used most often
|
||||
use argh::FromArgs;
|
||||
use ethers::types::U64;
|
||||
use log::trace;
|
||||
use prettytable::{row, Table};
|
||||
|
||||
@ -21,7 +22,10 @@ struct BackendRpcData<'a> {
|
||||
// tier: u64,
|
||||
// backup: bool,
|
||||
// block_data_limit: u64,
|
||||
head_block: u64,
|
||||
requests: u64,
|
||||
head_latency: f64,
|
||||
request_latency: f64,
|
||||
}
|
||||
|
||||
impl PopularityContestSubCommand {
|
||||
@ -56,10 +60,6 @@ impl PopularityContestSubCommand {
|
||||
.as_str()
|
||||
.unwrap();
|
||||
|
||||
if name.ends_with("http") {
|
||||
continue;
|
||||
}
|
||||
|
||||
let tier = conn.get("tier").unwrap().as_u64().unwrap();
|
||||
|
||||
// let backup = conn.get("backup").unwrap().as_bool().unwrap();
|
||||
@ -72,12 +72,31 @@ impl PopularityContestSubCommand {
|
||||
|
||||
let requests = conn.get("total_requests").unwrap().as_u64().unwrap();
|
||||
|
||||
let head_block = conn
|
||||
.get("head_block")
|
||||
.and_then(|x| x.get("block"))
|
||||
.and_then(|x| x.get("number"))
|
||||
.and_then(|x| U64::from_str(x.as_str().unwrap()).ok())
|
||||
.map(|x| x.as_u64())
|
||||
.unwrap_or_default();
|
||||
|
||||
let head_latency = conn.get("head_latency").unwrap().as_f64().unwrap();
|
||||
|
||||
let request_latency = conn
|
||||
.get("request_latency")
|
||||
.unwrap_or(&serde_json::Value::Null)
|
||||
.as_f64()
|
||||
.unwrap_or_default();
|
||||
|
||||
let rpc_data = BackendRpcData {
|
||||
name,
|
||||
// tier,
|
||||
// backup,
|
||||
// block_data_limit,
|
||||
requests,
|
||||
head_block,
|
||||
head_latency,
|
||||
request_latency,
|
||||
};
|
||||
|
||||
total_requests += rpc_data.requests;
|
||||
@ -97,7 +116,10 @@ impl PopularityContestSubCommand {
|
||||
"tier",
|
||||
"rpc_requests",
|
||||
"tier_request_pct",
|
||||
"total_pct"
|
||||
"total_pct",
|
||||
"head_block",
|
||||
"head_latency",
|
||||
"request_latency",
|
||||
]);
|
||||
|
||||
let total_requests = total_requests as f32;
|
||||
@ -125,7 +147,10 @@ impl PopularityContestSubCommand {
|
||||
tier,
|
||||
rpc.requests,
|
||||
tier_request_pct,
|
||||
total_request_pct
|
||||
total_request_pct,
|
||||
rpc.head_block,
|
||||
format!("{:.3}", rpc.head_latency),
|
||||
format!("{:.3}", rpc.request_latency),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user