-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
|
||
use crate::app::App; | ||
|
||
const EMIT_METRICS_INTERVAL: Duration = Duration::from_secs(1); | ||
|
||
pub async fn emit_metrics(app: Arc<App>) -> eyre::Result<()> { | ||
loop { | ||
let chain_ids = app.db.get_network_chain_ids().await?; | ||
|
||
for chain_id in chain_ids { | ||
let stats = app.db.get_stats(chain_id).await?; | ||
|
||
// TODO: Add labels for env, etc. | ||
let labels = [("chain_id", chain_id.to_string())]; | ||
|
||
metrics::gauge!("pending_txs", stats.pending_txs as f64, &labels); | ||
metrics::gauge!("mined_txs", stats.mined_txs as f64, &labels); | ||
metrics::gauge!( | ||
"finalized_txs", | ||
stats.finalized_txs as f64, | ||
&labels | ||
); | ||
metrics::gauge!( | ||
"total_indexed_blocks", | ||
stats.total_indexed_blocks as f64, | ||
&labels | ||
); | ||
metrics::gauge!("block_fees", stats.block_txs as f64, &labels); | ||
metrics::gauge!("block_txs", stats.block_txs as f64, &labels); | ||
} | ||
|
||
tokio::time::sleep(EMIT_METRICS_INTERVAL).await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters