logging improvements

This commit is contained in:
Bryan Stitt 2023-04-10 16:05:53 -07:00
parent 29c015508a
commit ed5ca0575c
3 changed files with 31 additions and 28 deletions

@ -575,27 +575,28 @@ impl Web3ProxyApp {
// create a channel for receiving stats
// we do this in a channel so we don't slow down our response to the users
// stats can be saved in mysql, influxdb, both, or none
let stat_sender = if let Some(emitter_spawn) = StatBuffer::try_spawn(
top_config.app.chain_id,
top_config
.app
.influxdb_bucket
.clone()
.context("No influxdb bucket was provided")?,
db_conn.clone(),
influxdb_client.clone(),
60,
1,
BILLING_PERIOD_SECONDS,
stat_buffer_shutdown_receiver,
)? {
// since the database entries are used for accounting, we want to be sure everything is saved before exiting
important_background_handles.push(emitter_spawn.background_handle);
let mut stat_sender = None;
if let Some(influxdb_bucket) = top_config.app.influxdb_bucket.clone() {
if let Some(spawned_stat_buffer) = StatBuffer::try_spawn(
top_config.app.chain_id,
influxdb_bucket,
db_conn.clone(),
influxdb_client.clone(),
60,
1,
BILLING_PERIOD_SECONDS,
stat_buffer_shutdown_receiver,
)? {
// since the database entries are used for accounting, we want to be sure everything is saved before exiting
important_background_handles.push(spawned_stat_buffer.background_handle);
Some(emitter_spawn.stat_sender)
} else {
None
};
stat_sender = Some(spawned_stat_buffer.stat_sender);
}
}
if stat_sender.is_none() {
info!("stats will not be collected");
}
// make a http shared client
// TODO: can we configure the connection pool? should we?

@ -131,6 +131,7 @@ fn main() -> anyhow::Result<()> {
vec![
"info",
"ethers=debug",
"ethers_providers=debug",
"redis_rate_limit=debug",
"web3_proxy=trace",
"web3_proxy_cli=trace",
@ -142,6 +143,7 @@ fn main() -> anyhow::Result<()> {
vec![
"info",
"ethers=debug",
"ethers_providers=warn",
"redis_rate_limit=debug",
"web3_proxy=debug",
"web3_proxy_cli=debug",

@ -1001,6 +1001,7 @@ impl Web3Rpcs {
request_metadata.no_servers.fetch_add(1, Ordering::Release);
}
// TODO: don't break. wait up to X seconds for a sever
break;
}
}
@ -1021,28 +1022,27 @@ impl Web3Rpcs {
let num_conns = self.by_name.read().len();
let num_skipped = skip_rpcs.len();
let consensus = watch_consensus_connections.borrow();
let head_block_num = consensus.as_ref().map(|x| x.head_block.number());
let head_block_num = watch_consensus_connections
.borrow()
.as_ref()
.map(|x| *x.head_block.number());
// TODO: error? warn? debug? trace?
if num_skipped == 0 {
error!(
"No servers synced ({:?}-{:?}, {:?}) ({} known). None skipped",
"No servers synced (min {:?}, max {:?}, head {:?}) ({} known). None skipped",
min_block_needed, max_block_needed, head_block_num, num_conns
);
// TODO: remove this, or move to trace level
// debug!("{}", serde_json::to_string(&request).unwrap());
} else {
// TODO: error? warn? debug? trace?
error!(
"Requested data is not available ({:?}-{:?}, {:?}) ({} skipped, {} known)",
"Requested data is not available (min {:?}, max {:?}, head {:?}) ({} skipped, {} known)",
min_block_needed, max_block_needed, head_block_num, num_skipped, num_conns
);
}
drop(consensus);
// TODO: what error code?
// cloudflare gives {"jsonrpc":"2.0","error":{"code":-32043,"message":"Requested data cannot be older than 128 blocks."},"id":1}
Ok(JsonRpcForwardedResponse::from_str(