Skip to content

cranker: emit cluster name in metrics #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crankers/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ async fn main() -> anyhow::Result<(), anyhow::Error> {
async move {
let metrics_client = RpcClient::new_with_timeout(args.rpc_url, Duration::from_secs(60));
loop {
if let Err(e) = emit_vault_metrics(&metrics_client, epoch_length).await {
if let Err(e) =
emit_vault_metrics(&metrics_client, epoch_length, &args.cluster.to_string())
.await
{
error!("Failed to emit metrics: {}", e);
}
tokio::time::sleep(Duration::from_secs(args.metrics_interval)).await;
Expand Down
19 changes: 17 additions & 2 deletions crankers/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;

use jito_jsm_core::get_epoch;
use jito_vault_core::config::Config;
use log::error;
use solana_metrics::datapoint_info;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::{program_pack::Pack, pubkey::Pubkey, signature::Keypair};
Expand All @@ -13,6 +14,7 @@ use crate::vault_handler::VaultHandler;
pub async fn emit_vault_metrics(
rpc_client: &RpcClient,
config_epoch_length: u64,
cluster_name: &str,
) -> anyhow::Result<()> {
let slot = rpc_client.get_slot().await?;
let epoch = slot / config_epoch_length;
Expand Down Expand Up @@ -92,12 +94,23 @@ pub async fn emit_vault_metrics(
.get(&vault.vrt_mint)
.ok_or_else(|| anyhow::anyhow!("Mint not found in map"))?;

let st_deposit_account: &TokenAccount = st_ata_map
let try_st_deposit_account = st_ata_map
.get(&get_associated_token_address(
address,
&vault.supported_mint,
))
.ok_or_else(|| anyhow::anyhow!("ST deposit account not found in map"))?;
.ok_or_else(|| anyhow::anyhow!("ST deposit account not found in map"));

if try_st_deposit_account.is_err() {
error!(
"Failed to get ST deposit account for vault {}: {}",
address,
try_st_deposit_account.unwrap_err()
);
continue;
}

let st_deposit_account = try_st_deposit_account.unwrap();

datapoint_info!(
"restaking-vault-supply",
Expand All @@ -109,6 +122,7 @@ pub async fn emit_vault_metrics(
("vrt_supply_external", vrt_mint.supply as i64, i64),
("st_supply_internal", vault.tokens_deposited() as i64, i64),
("st_supply_external", st_deposit_account.amount as i64, i64),
"cluster" => cluster_name,
);
}

Expand All @@ -128,6 +142,7 @@ pub async fn emit_vault_metrics(
num_vault_operator_delegations_updated,
i64
),
"cluster" => cluster_name,
);

Ok(())
Expand Down