lower log level
This commit is contained in:
parent
30eb6e91bf
commit
9929e59f04
@ -131,22 +131,24 @@ fn main() -> anyhow::Result<()> {
|
|||||||
vec![
|
vec![
|
||||||
"info",
|
"info",
|
||||||
"ethers=debug",
|
"ethers=debug",
|
||||||
"ethers_providers=debug",
|
|
||||||
"ethers_providers::rpc=off",
|
"ethers_providers::rpc=off",
|
||||||
|
"ethers_providers=debug",
|
||||||
"redis_rate_limit=debug",
|
"redis_rate_limit=debug",
|
||||||
"web3_proxy=trace",
|
|
||||||
"web3_proxy_cli=trace",
|
|
||||||
"web3_proxy::rpcs::blockchain=info",
|
"web3_proxy::rpcs::blockchain=info",
|
||||||
"web3_proxy::rpcs::request=debug",
|
"web3_proxy::rpcs::request=debug",
|
||||||
|
// "web3_proxy::stats::influxdb_queries=trace",
|
||||||
|
"web3_proxy=trace",
|
||||||
|
"web3_proxy_cli=trace",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
vec![
|
vec![
|
||||||
"info",
|
"info",
|
||||||
"ethers=debug",
|
"ethers=debug",
|
||||||
"ethers_providers=error",
|
|
||||||
"ethers_providers::rpc=off",
|
"ethers_providers::rpc=off",
|
||||||
|
"ethers_providers=error",
|
||||||
"redis_rate_limit=debug",
|
"redis_rate_limit=debug",
|
||||||
|
// "web3_proxy::stats::influxdb_queries=trace",
|
||||||
"web3_proxy=debug",
|
"web3_proxy=debug",
|
||||||
"web3_proxy_cli=debug",
|
"web3_proxy_cli=debug",
|
||||||
]
|
]
|
||||||
|
@ -20,7 +20,7 @@ use hashbrown::HashMap;
|
|||||||
use influxdb2::models::Query;
|
use influxdb2::models::Query;
|
||||||
use influxdb2::FromDataPoint;
|
use influxdb2::FromDataPoint;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{info, warn};
|
use log::trace;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::{json, Number, Value};
|
use serde_json::{json, Number, Value};
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ pub async fn query_user_stats<'a>(
|
|||||||
.influxdb_bucket
|
.influxdb_bucket
|
||||||
.clone()
|
.clone()
|
||||||
.context("No influxdb bucket was provided")?; // "web3_proxy";
|
.context("No influxdb bucket was provided")?; // "web3_proxy";
|
||||||
info!("Bucket is {:?}", bucket);
|
trace!("Bucket is {:?}", bucket);
|
||||||
|
|
||||||
// , "archive_needed", "error_response"
|
// , "archive_needed", "error_response"
|
||||||
let mut group_columns = vec![
|
let mut group_columns = vec![
|
||||||
@ -158,15 +158,16 @@ pub async fn query_user_stats<'a>(
|
|||||||
StatType::Detailed => "".to_string(),
|
StatType::Detailed => "".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
info!(
|
trace!(
|
||||||
"Query start and stop are: {:?} {:?}",
|
"Query start and stop are: {:?} {:?}",
|
||||||
query_start, query_stop
|
query_start,
|
||||||
|
query_stop
|
||||||
);
|
);
|
||||||
info!("Query column parameters are: {:?}", stats_column);
|
trace!("Query column parameters are: {:?}", stats_column);
|
||||||
info!("Query measurement is: {:?}", measurement);
|
trace!("Query measurement is: {:?}", measurement);
|
||||||
info!("Filters are: {:?} {:?}", filter_field, filter_chain_id);
|
trace!("Filters are: {:?} {:?}", filter_field, filter_chain_id);
|
||||||
info!("Group is: {:?}", group);
|
trace!("Group is: {:?}", group);
|
||||||
info!("window seconds are: {:?}", query_window_seconds);
|
trace!("window seconds are: {:?}", query_window_seconds);
|
||||||
|
|
||||||
// These are taken care of probably ...
|
// These are taken care of probably ...
|
||||||
// reg. fields, collect: backend_requests, frontend_requests, cache_hits, cache_misses, total_request_bytes, total_response_bytes, total_response_millis
|
// reg. fields, collect: backend_requests, frontend_requests, cache_hits, cache_misses, total_request_bytes, total_response_bytes, total_response_millis
|
||||||
@ -196,14 +197,14 @@ pub async fn query_user_stats<'a>(
|
|||||||
|> group()
|
|> group()
|
||||||
"#);
|
"#);
|
||||||
|
|
||||||
info!("Raw query to db is: {:?}", query);
|
trace!("Raw query to db is: {:?}", query);
|
||||||
let query = Query::new(query.to_string());
|
let query = Query::new(query.to_string());
|
||||||
info!("Query to db is: {:?}", query);
|
trace!("Query to db is: {:?}", query);
|
||||||
|
|
||||||
// TODO: do not unwrap. add this error to FrontErrorResponse
|
// TODO: do not unwrap. add this error to FrontErrorResponse
|
||||||
// TODO: StatType::Aggregated and StatType::Detailed might need different types
|
// TODO: StatType::Aggregated and StatType::Detailed might need different types
|
||||||
// let unparsed: serde_json::Value = serde_json::Value::Array(influxdb_client.query(Some(query.clone())).await?);
|
// let unparsed: serde_json::Value = serde_json::Value::Array(influxdb_client.query(Some(query.clone())).await?);
|
||||||
// info!("Direct response is: {:?}", unparsed);
|
// trace!("Direct response is: {:?}", unparsed);
|
||||||
|
|
||||||
// Return a different result based on the query
|
// Return a different result based on the query
|
||||||
let datapoints = match stat_response_type {
|
let datapoints = match stat_response_type {
|
||||||
@ -211,13 +212,13 @@ pub async fn query_user_stats<'a>(
|
|||||||
let influx_responses: Vec<AggregatedRpcAccounting> = influxdb_client
|
let influx_responses: Vec<AggregatedRpcAccounting> = influxdb_client
|
||||||
.query::<AggregatedRpcAccounting>(Some(query))
|
.query::<AggregatedRpcAccounting>(Some(query))
|
||||||
.await?;
|
.await?;
|
||||||
info!("Influx responses are {:?}", &influx_responses);
|
trace!("Influx responses are {:?}", &influx_responses);
|
||||||
for res in &influx_responses {
|
for res in &influx_responses {
|
||||||
info!("Resp is: {:?}", res);
|
trace!("Resp is: {:?}", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// let tmp = influx_responses.into_iter().group_by(|x| {x.time.timestamp()}).into_iter().collect::<Vec<_>>();
|
// let tmp = influx_responses.into_iter().group_by(|x| {x.time.timestamp()}).into_iter().collect::<Vec<_>>();
|
||||||
// info!("Printing grouped item {}", tmp);
|
// trace!("Printing grouped item {}", tmp);
|
||||||
|
|
||||||
// Group by all fields together ..
|
// Group by all fields together ..
|
||||||
// let influx_responses = Vec::new();
|
// let influx_responses = Vec::new();
|
||||||
@ -229,7 +230,7 @@ pub async fn query_user_stats<'a>(
|
|||||||
// (x.time.clone(), x)
|
// (x.time.clone(), x)
|
||||||
// })
|
// })
|
||||||
// .into_group_map();
|
// .into_group_map();
|
||||||
// info!("Grouped items are {:?}", grouped_items);
|
// trace!("Grouped items are {:?}", grouped_items);
|
||||||
|
|
||||||
influx_responses
|
influx_responses
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -237,7 +238,7 @@ pub async fn query_user_stats<'a>(
|
|||||||
.into_group_map()
|
.into_group_map()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(group, grouped_items)| {
|
.map(|(group, grouped_items)| {
|
||||||
info!("Group is: {:?}", group);
|
trace!("Group is: {:?}", group);
|
||||||
|
|
||||||
// Now put all the fields next to each other
|
// Now put all the fields next to each other
|
||||||
// (there will be exactly one field per timestamp, but we want to arrive at a new object)
|
// (there will be exactly one field per timestamp, but we want to arrive at a new object)
|
||||||
@ -250,23 +251,23 @@ pub async fn query_user_stats<'a>(
|
|||||||
out.insert("method".to_owned(), json!("null"));
|
out.insert("method".to_owned(), json!("null"));
|
||||||
|
|
||||||
for x in grouped_items {
|
for x in grouped_items {
|
||||||
info!("Iterating over grouped item {:?}", x);
|
trace!("Iterating over grouped item {:?}", x);
|
||||||
|
|
||||||
let key = format!("total_{}", x._field).to_string();
|
let key = format!("total_{}", x._field).to_string();
|
||||||
info!("Looking at: {:?}", key);
|
trace!("Looking at {:?}: {:?}", key, x._value);
|
||||||
|
|
||||||
// Insert it once, and then fix it
|
// Insert it once, and then fix it
|
||||||
match out.get_mut(&key) {
|
match out.get_mut(&key) {
|
||||||
Some(existing) => {
|
Some(existing) => {
|
||||||
match existing {
|
match existing {
|
||||||
Value::Number(old_value) => {
|
Value::Number(old_value) => {
|
||||||
|
trace!("Old value is {:?}", old_value);
|
||||||
// unwrap will error when someone has too many credits ..
|
// unwrap will error when someone has too many credits ..
|
||||||
let old_value = old_value.as_i64().unwrap();
|
let old_value = old_value.as_i64().unwrap();
|
||||||
warn!("Old value is {:?}", old_value);
|
|
||||||
*existing = serde_json::Value::Number(Number::from(
|
*existing = serde_json::Value::Number(Number::from(
|
||||||
old_value + x._value,
|
old_value + x._value,
|
||||||
));
|
));
|
||||||
warn!("New value is {:?}", old_value);
|
trace!("New value is {:?}", existing);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
panic!("Should be nothing but a number")
|
panic!("Should be nothing but a number")
|
||||||
@ -274,7 +275,7 @@ pub async fn query_user_stats<'a>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
warn!("Does not exist yet! Insert new!");
|
trace!("Does not exist yet! Insert new!");
|
||||||
out.insert(key, serde_json::Value::Number(Number::from(x._value)));
|
out.insert(key, serde_json::Value::Number(Number::from(x._value)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -324,9 +325,9 @@ pub async fn query_user_stats<'a>(
|
|||||||
let influx_responses: Vec<DetailedRpcAccounting> = influxdb_client
|
let influx_responses: Vec<DetailedRpcAccounting> = influxdb_client
|
||||||
.query::<DetailedRpcAccounting>(Some(query))
|
.query::<DetailedRpcAccounting>(Some(query))
|
||||||
.await?;
|
.await?;
|
||||||
info!("Influx responses are {:?}", &influx_responses);
|
trace!("Influx responses are {:?}", &influx_responses);
|
||||||
for res in &influx_responses {
|
for res in &influx_responses {
|
||||||
info!("Resp is: {:?}", res);
|
trace!("Resp is: {:?}", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group by all fields together ..
|
// Group by all fields together ..
|
||||||
@ -349,23 +350,25 @@ pub async fn query_user_stats<'a>(
|
|||||||
out.insert("method".to_owned(), json!(method));
|
out.insert("method".to_owned(), json!(method));
|
||||||
|
|
||||||
for x in grouped_items {
|
for x in grouped_items {
|
||||||
info!("Iterating over grouped item {:?}", x);
|
trace!("Iterating over grouped item {:?}", x);
|
||||||
|
|
||||||
let key = format!("total_{}", x._field).to_string();
|
let key = format!("total_{}", x._field).to_string();
|
||||||
info!("Looking at: {:?}", key);
|
trace!("Looking at {:?}: {:?}", key, x._value);
|
||||||
|
|
||||||
// Insert it once, and then fix it
|
// Insert it once, and then fix it
|
||||||
match out.get_mut(&key) {
|
match out.get_mut(&key) {
|
||||||
Some(existing) => {
|
Some(existing) => {
|
||||||
match existing {
|
match existing {
|
||||||
Value::Number(old_value) => {
|
Value::Number(old_value) => {
|
||||||
|
trace!("Old value is {:?}", old_value);
|
||||||
|
|
||||||
// unwrap will error when someone has too many credits ..
|
// unwrap will error when someone has too many credits ..
|
||||||
let old_value = old_value.as_i64().unwrap();
|
let old_value = old_value.as_i64().unwrap();
|
||||||
warn!("Old value is {:?}", old_value);
|
|
||||||
*existing = serde_json::Value::Number(Number::from(
|
*existing = serde_json::Value::Number(Number::from(
|
||||||
old_value + x._value,
|
old_value + x._value,
|
||||||
));
|
));
|
||||||
warn!("New value is {:?}", old_value);
|
|
||||||
|
trace!("New value is {:?}", existing.as_i64());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
panic!("Should be nothing but a number")
|
panic!("Should be nothing but a number")
|
||||||
@ -373,7 +376,7 @@ pub async fn query_user_stats<'a>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
warn!("Does not exist yet! Insert new!");
|
trace!("Does not exist yet! Insert new!");
|
||||||
out.insert(key, serde_json::Value::Number(Number::from(x._value)));
|
out.insert(key, serde_json::Value::Number(Number::from(x._value)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user