Skip to content

Commit

Permalink
added metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Oct 19, 2023
1 parent 3d89dbc commit 25c76b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ panic = "unwind"

[profile.release-lto]
inherits = "release"
codegen-units = 1
lto = "fat"
opt-level = 3
panic = "abort"
incremental = false
opt-level = 1
panic = "unwind"

#[profile.release-lto]
#inherits = "release"
#codegen-units = 1
#lto = "fat"
#opt-level = 3
#panic = "abort"
33 changes: 30 additions & 3 deletions src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ pub async fn run_stats(

for (sender, stats) in &transfer_stats.per_sender {
metrics += &format!(
"{}\n{}\nsenders_count{{chain_id=\"{}\", sender=\"{:#x}\"}} {}\n",
"# HELP senders_count Number of distinct receivers",
"# TYPE senders_count counter",
"{}\n{}\nreceivers_count{{chain_id=\"{}\", receiver=\"{:#x}\"}} {}\n",
"# HELP receivers_count Number of distinct receivers",
"# TYPE receivers_count counter",
chain_cfg.chain_id,
sender,
stats.per_receiver.len(),
Expand All @@ -84,6 +84,33 @@ pub async fn run_stats(
sender,
u256_to_rust_dec(token_transferred.unwrap_or(U256::zero()), None).unwrap(),
);

metrics += &format!(
"{}\n{}\npayment_count{{chain_id=\"{}\", sender=\"{:#x}\"}} {}\n",
"# HELP payment_count Number of distinct payments",
"# TYPE payment_count counter",
chain_cfg.chain_id,
sender,
stats.all.done_count,
);

metrics += &format!(
"{}\n{}\ntransaction_count{{chain_id=\"{}\", sender=\"{:#x}\"}} {}\n",
"# HELP transaction_count Number of web3 transactions",
"# TYPE transaction_count counter",
chain_cfg.chain_id,
sender,
stats.all.transaction_ids.len(),
);

metrics += &format!(
"{}\n{}\nfee_paid{{chain_id=\"{}\", sender=\"{:#x}\"}} {}\n",
"# HELP fee_paid Total fee paid",
"# TYPE fee_paid counter",
chain_cfg.chain_id,
sender,
u256_to_rust_dec(stats.all.fee_paid, None).unwrap_or_default(),
);
}

println!(
Expand Down

0 comments on commit 25c76b7

Please sign in to comment.