From ed5ca0575c3f40ad52b7540df36d01018547c1df Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 10 Apr 2023 16:05:53 -0700 Subject: [PATCH] logging improvements --- web3_proxy/src/app/mod.rs | 41 ++++++++++++----------- web3_proxy/src/bin/web3_proxy_cli/main.rs | 2 ++ web3_proxy/src/rpcs/many.rs | 16 ++++----- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index 21ba8d8b..8edbb93d 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -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? diff --git a/web3_proxy/src/bin/web3_proxy_cli/main.rs b/web3_proxy/src/bin/web3_proxy_cli/main.rs index 033ba6ce..692324f0 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/main.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/main.rs @@ -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", diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index 5998e269..d461063c 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -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(