Skip to content
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

feat: Remove metrics crate #1902

Merged
merged 17 commits into from
May 14, 2024
Merged
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
8 changes: 3 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/bin/contract-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ thiserror.workspace = true
chrono.workspace = true
serde_json.workspace = true
ethabi.workspace = true
metrics.workspace = true
vise.workspace = true
hex.workspace = true
serde = { workspace = true, features = ["derive"] }
structopt.workspace = true
Expand Down
1 change: 1 addition & 0 deletions core/bin/contract-verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use zksync_utils::wait_for_tasks::ManagedTasks;
use crate::verifier::ContractVerifier;

pub mod error;
mod metrics;
pub mod verifier;
pub mod zksolc_utils;
pub mod zkvyper_utils;
Expand Down
14 changes: 14 additions & 0 deletions core/bin/contract-verifier/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::time::Duration;

use vise::{Buckets, Histogram, Metrics};

#[derive(Debug, Metrics)]
#[metrics(prefix = "api_contract_verifier")]
pub(crate) struct ApiContractVerifierMetrics {
#[metrics(buckets = Buckets::LATENCIES)]
pub request_processing_time: Histogram<Duration>,
}

#[vise::register]
pub(crate) static API_CONTRACT_VERIFIER_METRICS: vise::Global<ApiContractVerifierMetrics> =
vise::Global::new();
8 changes: 4 additions & 4 deletions core/bin/contract-verifier/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use zksync_types::{

use crate::{
error::ContractVerifierError,
metrics::API_CONTRACT_VERIFIER_METRICS,
zksolc_utils::{Optimizer, Settings, Source, StandardJson, ZkSolc, ZkSolcInput, ZkSolcOutput},
zkvyper_utils::{ZkVyper, ZkVyperInput},
};
Expand Down Expand Up @@ -523,10 +524,9 @@ impl JobProcessor for ContractVerifier {
let verification_result = Self::verify(&mut connection, job, config).await;
Self::process_result(&mut connection, job_id, verification_result).await;

metrics::histogram!(
"api.contract_verifier.request_processing_time",
started_at.elapsed()
);
API_CONTRACT_VERIFIER_METRICS
.request_processing_time
.observe(started_at.elapsed());
Ok(())
})
}
Expand Down
1 change: 0 additions & 1 deletion core/lib/zksync_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_yaml.workspace = true
itertools.workspace = true
metrics.workspace = true
ctrlc.workspace = true
rand.workspace = true

Expand Down
1 change: 0 additions & 1 deletion core/node/house_keeper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ async-trait.workspace = true
tokio = { workspace = true, features = ["time"] }
anyhow.workspace = true
tracing.workspace = true
metrics.workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_trait::async_trait;
use prover_dal::{Prover, ProverDal};
use zksync_dal::ConnectionPool;

use crate::periodic_job::PeriodicJob;
use crate::{metrics::PROVER_FRI_METRICS, periodic_job::PeriodicJob};

#[derive(Debug)]
pub struct FriProofCompressorJobRetryManager {
Expand Down Expand Up @@ -48,7 +48,9 @@ impl PeriodicJob for FriProofCompressorJobRetryManager {
for stuck_job in stuck_jobs {
tracing::info!("re-queuing fri proof compressor job {:?}", stuck_job);
}
metrics::counter!("prover_fri.proof_compressor.requeued_jobs", job_len as u64);
PROVER_FRI_METRICS
.proof_compressor_requeued_jobs
.inc_by(job_len as u64);
Ok(())
}

Expand Down
31 changes: 10 additions & 21 deletions core/node/house_keeper/src/fri_proof_compressor_queue_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use prover_dal::{Prover, ProverDal};
use zksync_dal::ConnectionPool;
use zksync_types::prover_dal::JobCountStatistics;

use crate::periodic_job::PeriodicJob;

const PROOF_COMPRESSOR_SERVICE_NAME: &str = "proof_compressor";
use crate::{
metrics::{JobStatus, PROVER_FRI_METRICS},
periodic_job::PeriodicJob,
};

#[derive(Debug)]
pub struct FriProofCompressorStatsReporter {
Expand Down Expand Up @@ -48,17 +49,9 @@ impl PeriodicJob for FriProofCompressorStatsReporter {
);
}

metrics::gauge!(
format!("prover_fri.{}.jobs", PROOF_COMPRESSOR_SERVICE_NAME),
stats.queued as f64,
"type" => "queued"
);

metrics::gauge!(
format!("prover_fri.{}.jobs", PROOF_COMPRESSOR_SERVICE_NAME),
stats.in_progress as f64,
"type" => "in_progress"
);
PROVER_FRI_METRICS.proof_compressor_jobs[&JobStatus::Queued].set(stats.queued as u64);
PROVER_FRI_METRICS.proof_compressor_jobs[&JobStatus::InProgress]
.set(stats.in_progress as u64);

let oldest_not_compressed_batch = self
.pool
Expand All @@ -70,13 +63,9 @@ impl PeriodicJob for FriProofCompressorStatsReporter {
.await;

if let Some(l1_batch_number) = oldest_not_compressed_batch {
metrics::gauge!(
format!(
"prover_fri.{}.oldest_not_compressed_batch",
PROOF_COMPRESSOR_SERVICE_NAME
),
l1_batch_number.0 as f64
);
PROVER_FRI_METRICS
.proof_compressor_oldest_uncompressed_batch
.set(l1_batch_number.0 as u64);
}

Ok(())
Expand Down
6 changes: 4 additions & 2 deletions core/node/house_keeper/src/fri_prover_job_retry_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_trait::async_trait;
use prover_dal::{Prover, ProverDal};
use zksync_dal::ConnectionPool;

use crate::periodic_job::PeriodicJob;
use crate::{metrics::SERVER_METRICS, periodic_job::PeriodicJob};

#[derive(Debug)]
pub struct FriProverJobRetryManager {
Expand Down Expand Up @@ -48,7 +48,9 @@ impl PeriodicJob for FriProverJobRetryManager {
for stuck_job in stuck_jobs {
tracing::info!("re-queuing fri prover job {:?}", stuck_job);
}
metrics::counter!("server.prover_fri.requeued_jobs", job_len as u64);
SERVER_METRICS
.prover_fri_requeued_jobs
.inc_by(job_len as u64);
Ok(())
}

Expand Down
59 changes: 27 additions & 32 deletions core/node/house_keeper/src/fri_prover_queue_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use prover_dal::{Prover, ProverDal};
use zksync_config::configs::fri_prover_group::FriProverGroupConfig;
use zksync_dal::{ConnectionPool, Core, CoreDal};

use crate::periodic_job::PeriodicJob;
use crate::{metrics::FRI_PROVER_METRICS, periodic_job::PeriodicJob};

#[derive(Debug)]
pub struct FriProverStatsReporter {
Expand Down Expand Up @@ -57,22 +57,19 @@ impl PeriodicJob for FriProverStatsReporter {
.get_group_id_for_circuit_id_and_aggregation_round(circuit_id, aggregation_round)
.unwrap_or(u8::MAX);

metrics::gauge!(
"fri_prover.prover.jobs",
stats.queued as f64,
"type" => "queued",
"circuit_id" => circuit_id.to_string(),
"aggregation_round" => aggregation_round.to_string(),
"prover_group_id" => group_id.to_string(),
FRI_PROVER_METRICS.report_prover_jobs(
"queued",
circuit_id,
aggregation_round,
group_id,
stats.queued as u64,
);

metrics::gauge!(
"fri_prover.prover.jobs",
stats.in_progress as f64,
"type" => "in_progress",
"circuit_id" => circuit_id.to_string(),
"aggregation_round" => aggregation_round.to_string(),
"prover_group_id" => group_id.to_string(),
FRI_PROVER_METRICS.report_prover_jobs(
"in_progress",
circuit_id,
aggregation_round,
group_id,
stats.in_progress as u64,
);
}

Expand All @@ -82,10 +79,9 @@ impl PeriodicJob for FriProverStatsReporter {
.await;

for ((circuit_id, aggregation_round), l1_batch_number) in lag_by_circuit_type {
metrics::gauge!(
"fri_prover.block_number", l1_batch_number.0 as f64,
"circuit_id" => circuit_id.to_string(),
"aggregation_round" => aggregation_round.to_string());
FRI_PROVER_METRICS.block_number
[&(circuit_id.to_string(), aggregation_round.to_string())]
.set(l1_batch_number.0 as u64);
}

// FIXME: refactor metrics here
Expand All @@ -97,7 +93,7 @@ impl PeriodicJob for FriProverStatsReporter {
.get_oldest_unpicked_batch()
.await
{
Some(l1_batch_number) => l1_batch_number.0 as f64,
Some(l1_batch_number) => l1_batch_number.0 as u64,
// if there is no unpicked batch in database, we use sealed batch number as a result
None => {
db_conn
Expand All @@ -106,20 +102,21 @@ impl PeriodicJob for FriProverStatsReporter {
.await
.unwrap()
.unwrap()
.0 as f64
.0 as u64
}
};
metrics::gauge!("fri_prover.oldest_unpicked_batch", oldest_unpicked_batch);
FRI_PROVER_METRICS
.oldest_unpicked_batch
.set(oldest_unpicked_batch);

if let Some(l1_batch_number) = db_conn
.proof_generation_dal()
.get_oldest_not_generated_batch()
.await
{
metrics::gauge!(
"fri_prover.oldest_not_generated_batch",
l1_batch_number.0 as f64
)
FRI_PROVER_METRICS
.oldest_not_generated_batch
.set(l1_batch_number.0 as u64);
}

for aggregation_round in 0..3 {
Expand All @@ -128,11 +125,9 @@ impl PeriodicJob for FriProverStatsReporter {
.min_unproved_l1_batch_number_for_aggregation_round(aggregation_round.into())
.await
{
metrics::gauge!(
"fri_prover.oldest_unprocessed_block_by_round",
l1_batch_number.0 as f64,
"aggregation_round" => aggregation_round.to_string()
)
FRI_PROVER_METRICS.oldest_unprocessed_block_by_round
[&aggregation_round.to_string()]
.set(l1_batch_number.0 as u64);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use zksync_config::configs::fri_witness_generator::WitnessGenerationTimeouts;
use zksync_dal::ConnectionPool;
use zksync_types::prover_dal::StuckJobs;

use crate::periodic_job::PeriodicJob;
use crate::{
metrics::{WitnessType, SERVER_METRICS},
periodic_job::PeriodicJob,
};

#[derive(Debug)]
pub struct FriWitnessGeneratorJobRetryManager {
Expand Down Expand Up @@ -33,10 +36,8 @@ impl FriWitnessGeneratorJobRetryManager {
for stuck_job in stuck_jobs {
tracing::info!("re-queuing {:?} {:?}", witness_type, stuck_job);
}
metrics::counter!(
format!("server.{:?}.requeued_jobs", witness_type),
stuck_jobs.len() as u64
);
SERVER_METRICS.requeued_jobs[&WitnessType::from(witness_type)]
.inc_by(stuck_jobs.len() as u64);
}

pub async fn requeue_stuck_witness_inputs_jobs(&mut self) {
Expand Down
Loading
Loading