Skip to content

Commit

Permalink
logging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
BlinkyStitt committed Apr 10, 2023
1 parent 29c0155 commit ed5ca05
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
43 changes: 22 additions & 21 deletions web3_proxy/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Some(emitter_spawn.stat_sender)
} else {
None
};
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);

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?
Expand Down
2 changes: 2 additions & 0 deletions web3_proxy/src/bin/web3_proxy_cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions web3_proxy/src/rpcs/many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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(
Expand Down

0 comments on commit ed5ca05

Please sign in to comment.