Skip to content

Commit dd39029

Browse files
devin-ai-integration[bot]Jayant Krishnamurthy
andauthored
chore: init KeeperMetrics with chain_id and provider_address, bump version (#2318)
* chore: init KeeperMetrics with chain_id and provider_address, bump version Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * fix: properly handle RwLock return values in KeeperMetrics::new Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * fix: use keys() and values() instead of iter() for map iteration Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * refactor: simplify KeeperMetrics::new to use Vec<(String, Address)> Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> * chore: update Cargo.lock with version bump Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Jayant Krishnamurthy <jayant@dourolabs.xyz>
1 parent bfd8c12 commit dd39029

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "7.4.0"
3+
version = "7.4.1"
44
edition = "2021"
55

66
[dependencies]

apps/fortuna/src/command/run.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ pub async fn run_keeper(
103103
rpc_metrics: Arc<RpcMetrics>,
104104
) -> Result<()> {
105105
let mut handles = Vec::new();
106-
let keeper_metrics = Arc::new(KeeperMetrics::new(metrics_registry).await);
106+
let keeper_metrics = Arc::new({
107+
let chain_labels: Vec<(String, Address)> = chains
108+
.iter()
109+
.map(|(id, state)| (id.clone(), state.provider_address))
110+
.collect();
111+
KeeperMetrics::new(metrics_registry.clone(), chain_labels).await
112+
});
107113
for (chain_id, chain_config) in chains {
108114
let chain_eth_config = config
109115
.chains

apps/fortuna/src/keeper.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ impl Default for KeeperMetrics {
128128
}
129129

130130
impl KeeperMetrics {
131-
pub async fn new(registry: Arc<RwLock<Registry>>) -> Self {
131+
pub async fn new(
132+
registry: Arc<RwLock<Registry>>,
133+
chain_labels: Vec<(String, Address)>,
134+
) -> Self {
132135
let mut writable_registry = registry.write().await;
133136
let keeper_metrics = KeeperMetrics::default();
134137

@@ -246,6 +249,60 @@ impl KeeperMetrics {
246249
keeper_metrics.gas_price_estimate.clone(),
247250
);
248251

252+
// *Important*: When adding a new metric:
253+
// 1. Register it above using `writable_registry.register(...)`
254+
// 2. Add a get_or_create call in the loop below to initialize it for each chain/provider pair
255+
for (chain_id, provider_address) in chain_labels {
256+
let account_label = AccountLabel {
257+
chain_id,
258+
address: provider_address.to_string(),
259+
};
260+
261+
let _ = keeper_metrics
262+
.current_sequence_number
263+
.get_or_create(&account_label);
264+
let _ = keeper_metrics
265+
.end_sequence_number
266+
.get_or_create(&account_label);
267+
let _ = keeper_metrics.balance.get_or_create(&account_label);
268+
let _ = keeper_metrics.collected_fee.get_or_create(&account_label);
269+
let _ = keeper_metrics.current_fee.get_or_create(&account_label);
270+
let _ = keeper_metrics
271+
.target_provider_fee
272+
.get_or_create(&account_label);
273+
let _ = keeper_metrics.total_gas_spent.get_or_create(&account_label);
274+
let _ = keeper_metrics
275+
.total_gas_fee_spent
276+
.get_or_create(&account_label);
277+
let _ = keeper_metrics.requests.get_or_create(&account_label);
278+
let _ = keeper_metrics
279+
.requests_processed
280+
.get_or_create(&account_label);
281+
let _ = keeper_metrics
282+
.requests_processed_success
283+
.get_or_create(&account_label);
284+
let _ = keeper_metrics
285+
.requests_processed_failure
286+
.get_or_create(&account_label);
287+
let _ = keeper_metrics
288+
.requests_reprocessed
289+
.get_or_create(&account_label);
290+
let _ = keeper_metrics.reveals.get_or_create(&account_label);
291+
let _ = keeper_metrics
292+
.request_duration_ms
293+
.get_or_create(&account_label);
294+
let _ = keeper_metrics.retry_count.get_or_create(&account_label);
295+
let _ = keeper_metrics
296+
.final_gas_multiplier
297+
.get_or_create(&account_label);
298+
let _ = keeper_metrics
299+
.final_fee_multiplier
300+
.get_or_create(&account_label);
301+
let _ = keeper_metrics
302+
.gas_price_estimate
303+
.get_or_create(&account_label);
304+
}
305+
249306
keeper_metrics
250307
}
251308
}

0 commit comments

Comments
 (0)