From b08a279b6008f89ad099b3396324d03f2cc7a67d Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 21 Jul 2023 16:29:10 -0700 Subject: [PATCH] add another field to try to handle improper de-duplication --- web3_proxy/src/app/mod.rs | 2 +- web3_proxy/src/stats/mod.rs | 2 ++ web3_proxy/src/stats/stat_buffer.rs | 18 ++++++++++++++++-- .../src/sub_commands/migrate_stats_to_v2.rs | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index 78ce9da0..4363278a 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -335,7 +335,7 @@ impl Web3ProxyApp { rpc_secret_key_cache.clone(), user_balance_cache.clone(), stat_buffer_shutdown_receiver, - 30, + 1, flush_stat_buffer_sender.clone(), flush_stat_buffer_receiver, )? { diff --git a/web3_proxy/src/stats/mod.rs b/web3_proxy/src/stats/mod.rs index d4b571f9..27ed10e8 100644 --- a/web3_proxy/src/stats/mod.rs +++ b/web3_proxy/src/stats/mod.rs @@ -481,6 +481,7 @@ impl BufferedRpcQueryStats { chain_id: u64, key: RpcQueryKey, instance: &str, + now: &str, ) -> anyhow::Result { let mut builder = DataPoint::builder(measurement) .tag("archive_needed", key.archive_needed.to_string()) @@ -489,6 +490,7 @@ impl BufferedRpcQueryStats { .tag("instance", instance) .tag("method", key.method) .tag("user_error_response", key.user_error_response.to_string()) + .tag("save_time", now) .timestamp(key.response_timestamp) .field("backend_requests", self.backend_requests as i64) .field("cache_hits", self.cache_hits as i64) diff --git a/web3_proxy/src/stats/stat_buffer.rs b/web3_proxy/src/stats/stat_buffer.rs index 28339a7a..06b9e852 100644 --- a/web3_proxy/src/stats/stat_buffer.rs +++ b/web3_proxy/src/stats/stat_buffer.rs @@ -401,12 +401,20 @@ impl StatBuffer { // TODO: use stream::iter properly to avoid allocating this Vec let mut points = vec![]; + let now = chrono::Utc::now().to_rfc3339(); + for (key, stat) in self.global_timeseries_buffer.drain() { // TODO: i don't like passing key (which came from the stat) to the function on the stat. but it works for now let new_frontend_requests = stat.frontend_requests; match stat - .build_timeseries_point("global_proxy", self.chain_id, key, &self.instance_hash) + .build_timeseries_point( + "global_proxy", + self.chain_id, + key, + &self.instance_hash, + &now, + ) .await { Ok(point) => { @@ -423,7 +431,13 @@ impl StatBuffer { for (key, stat) in self.opt_in_timeseries_buffer.drain() { // TODO: i don't like passing key (which came from the stat) to the function on the stat. but it works for now match stat - .build_timeseries_point("opt_in_proxy", self.chain_id, key, &self.instance_hash) + .build_timeseries_point( + "opt_in_proxy", + self.chain_id, + key, + &self.instance_hash, + &now, + ) .await { Ok(point) => { diff --git a/web3_proxy/src/sub_commands/migrate_stats_to_v2.rs b/web3_proxy/src/sub_commands/migrate_stats_to_v2.rs index 45c4b270..44986bcd 100644 --- a/web3_proxy/src/sub_commands/migrate_stats_to_v2.rs +++ b/web3_proxy/src/sub_commands/migrate_stats_to_v2.rs @@ -88,7 +88,7 @@ impl MigrateStatsToV2SubCommand { rpc_secret_key_cache, user_balance_cache, rpc_account_shutdown_recevier, - 30, + 60, flush_sender, flush_receiver, )