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

View File

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

View File

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

View File

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